log sessions.Save()

This commit is contained in:
sentriz
2019-06-27 13:32:58 +01:00
parent 65bdda4cc2
commit ea9ddc71f6
4 changed files with 28 additions and 15 deletions

View File

@@ -26,7 +26,7 @@ func (c *Controller) WithUserSession(next http.HandlerFunc) http.HandlerFunc {
username, ok := session.Values["user"].(string)
if !ok {
session.AddFlash("you are not authenticated")
session.Save(r, w)
sessionLogSave(w, r, session)
http.Redirect(w, r, "/admin/login", http.StatusSeeOther)
return
}
@@ -36,7 +36,7 @@ func (c *Controller) WithUserSession(next http.HandlerFunc) http.HandlerFunc {
// the username in the client's session no longer relates to a
// user in the database (maybe the user was deleted)
session.Options.MaxAge = -1
session.Save(r, w)
sessionLogSave(w, r, session)
http.Redirect(w, r, "/admin/login", http.StatusSeeOther)
return
}
@@ -53,7 +53,7 @@ func (c *Controller) WithAdminSession(next http.HandlerFunc) http.HandlerFunc {
user := r.Context().Value(contextUserKey).(*model.User)
if !user.IsAdmin {
session.AddFlash("you are not an admin")
session.Save(r, w)
sessionLogSave(w, r, session)
http.Redirect(w, r, "/admin/login", http.StatusSeeOther)
return
}