lets-go:11.5 logout
This commit is contained in:
parent
7aecca2131
commit
8a854768a0
@ -223,8 +223,14 @@ func (app *application) userLoginPost(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// userLoginPost ...
|
// userLoginPost ...
|
||||||
func (app *application) userLogoutPost(w http.ResponseWriter, r *http.Request) {
|
func (app *application) userLogoutPost(w http.ResponseWriter, r *http.Request) {
|
||||||
id := app.sessionManager.PopInt(r.Context(), "authenticatedUserID")
|
err := app.sessionManager.RenewToken(r.Context())
|
||||||
|
if err != nil {
|
||||||
|
app.serverError(w, r, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
app.sessionManager.Remove(r.Context(), "authenticatedUserID")
|
||||||
|
app.sessionManager.Put(r.Context(), "flash", fmt.Sprintf("You have been logged out."))
|
||||||
|
|
||||||
app.sessionManager.Put(r.Context(), "flash", fmt.Sprintf("LOGGED OUT USER %d! (not really)", id))
|
|
||||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user