aboutsummaryrefslogtreecommitdiff
path: root/src/user/routes.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/routes.go')
-rw-r--r--src/user/routes.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/user/routes.go b/src/user/routes.go
index 3bcab06..d8c8d43 100644
--- a/src/user/routes.go
+++ b/src/user/routes.go
@@ -56,7 +56,7 @@ var Routes = server.Routes{
func Create(s *server.Server) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- s.Ui.Render(w, "user/create", nil)
+ s.Ui.Render(w, r, "user/create", nil)
}
}
@@ -98,7 +98,7 @@ func Store(s *server.Server) http.HandlerFunc {
func LoginForm(s *server.Server) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- s.Ui.Render(w, "user/login", nil)
+ s.Ui.Render(w, r, "user/login", nil)
}
}
@@ -113,16 +113,16 @@ func Login(s *server.Server) http.HandlerFunc {
func Logout(s *server.Server) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- session := r.Context().Value("session").(*sessions.Session)
- session.Destroy(w)
+ if session := r.Context().Value(sessions.SessionCtxKey("session")); session != nil {
+ session.(*sessions.Session).Destroy(w)
+ }
http.Redirect(w, r, "/u/auth", http.StatusSeeOther)
}
}
func Show(s *server.Server) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
- session := r.Context().Value(sessions.SessionCtxKey("session")).(*sessions.Session)
- username := session.Get("username").(string)
- s.Ui.Render(w, "user/me", &struct{ Message, Username string }{"Congrats on getting this far!", username})
+ pageData := map[string]any{"message": "Congrats on getting this far!"}
+ s.Ui.Render(w, r, "user/me", pageData)
}
}