diff options
| author | Alexander Kavon <hawk@alexkavon.com> | 2023-11-28 05:24:30 -0500 |
|---|---|---|
| committer | Alexander Kavon <hawk@alexkavon.com> | 2023-11-28 05:24:30 -0500 |
| commit | 629b0189b7bf20c748a1d37f8803ad0e3ffb8a49 (patch) | |
| tree | 6692374508230b46be3aee323acd7aa25b3d4a91 /src/user | |
| parent | 7d7059d53891bc1abb284d9b288505a5d406b307 (diff) | |
working container compose w/database, no more auth package, message template partial, working html template writing, auth routes in user/routes.go
Diffstat (limited to 'src/user')
| -rw-r--r-- | src/user/routes.go | 50 | ||||
| -rw-r--r-- | src/user/user.go | 1 |
2 files changed, 44 insertions, 7 deletions
diff --git a/src/user/routes.go b/src/user/routes.go index 791213d..09c53b2 100644 --- a/src/user/routes.go +++ b/src/user/routes.go @@ -1,6 +1,7 @@ package user import ( + "fmt" "net/http" "gitlab.com/alexkavon/newsstand/src/server" @@ -8,16 +9,33 @@ import ( var Routes = server.Routes{ server.Route{ - Name: "Create", - Method: "GET", - Path: "/users/create", - AuthRequired: false, - HandlerFunc: Create, + Name: "Create", + Method: "GET", + Path: "/user/create", + HandlerFunc: Create, + }, + server.Route{ + Name: "Store", + Method: "POST", + Path: "/user", + HandlerFunc: Store, + }, + server.Route{ + Name: "LoginForm", + Method: "GET", + Path: "/user/auth", + HandlerFunc: LoginForm, + }, + server.Route{ + Name: "Authenticate", + Method: "POST", + Path: "/user/auth", + HandlerFunc: Authenticate, }, server.Route{ Name: "Me", Method: "GET", - Path: "/users/me", + Path: "/user/me", AuthRequired: true, HandlerFunc: Show, }, @@ -25,10 +43,28 @@ var Routes = server.Routes{ func Create(s *server.Server) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - s.Ui.Render(w, "users/create", nil) + s.Ui.Render(w, "user/create", nil) + } +} + +func Store(s *server.Server) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + r.ParseForm() + fmt.Println(r.PostForm) + s.Ui.Render(w, "core/messages", &struct{ Message string }{Message: "Congrats"}) } } +func LoginForm(s *server.Server) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + s.Ui.Render(w, "user/login", nil) + } +} + +func Authenticate(s *server.Server) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) {} +} + func Show(s *server.Server) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) {} } diff --git a/src/user/user.go b/src/user/user.go index 9845b1b..97fe74c 100644 --- a/src/user/user.go +++ b/src/user/user.go @@ -3,4 +3,5 @@ package user type User struct { Id int64 `json:"id"` Username string `json:"username"` + Karma uint64 `json:"karma"` } |
