aboutsummaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-30 00:46:05 +0300
committerAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-30 00:46:05 +0300
commit48a84eb03f6b17ee41d6f097c78d89488ba14e8c (patch)
tree5cef9486cf2bb07d828bfebe12e835e40f7f16f0 /controllers
parent96e2ce2e9d363a6296f9411ecb00168520258874 (diff)
Обновил сессии
Diffstat (limited to 'controllers')
-rw-r--r--controllers/user.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/controllers/user.go b/controllers/user.go
index a605c25..6685383 100644
--- a/controllers/user.go
+++ b/controllers/user.go
@@ -24,7 +24,13 @@ func (rt *Router) Login(w http.ResponseWriter, r *http.Request) {
}
sess := session.FromRequest(r)
- (*sess)["user"] = u
+ values := sess.Values(r.Context())
+ values["user"] = u
+
+ if err := sess.Save(w, r, values); err != nil {
+ mux.Render(w, r, mux.DefaultErrorHandler(err))
+ return
+ }
mux.Redirect(w, 302, "/")
return
@@ -34,7 +40,8 @@ func (rt *Router) Login(w http.ResponseWriter, r *http.Request) {
}
func (rt *Router) Logout(w http.ResponseWriter, r *http.Request) {
- session.Clear(w, r)
+ sess := session.FromRequest(r)
+ sess.Clear(w, r)
mux.Redirect(w, 302, "/")
}