Checking to see if a user is logged in, and logging a user our
This commit is contained in:
@ -494,3 +494,11 @@ func (m *Repository) PostShowLogin(w http.ResponseWriter, r *http.Request) {
|
||||
m.App.Session.Put(r.Context(), "flash", "Logged in successfully")
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// Logout logs a user out
|
||||
func (m *Repository) Logout(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO Use Redis to store the session. Check the documentation of scs package
|
||||
m.App.Session.Destroy(r.Context())
|
||||
m.App.Session.RenewToken(r.Context())
|
||||
http.Redirect(w, r, "/user/login", http.StatusSeeOther)
|
||||
}
|
||||
|
Reference in New Issue
Block a user