lets-go:11.0 very minimal first pass at logout
curious why `http.Redirect` does POST here? because i haven't handled any user input?
This commit is contained in:
parent
c1bb129b87
commit
165ee77a72
@ -188,3 +188,11 @@ func (app *application) userLoginPost(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// userLoginPost ...
|
||||
func (app *application) userLogoutPost(w http.ResponseWriter, r *http.Request) {
|
||||
id := app.sessionManager.PopInt(r.Context(), "authenticatedUserID")
|
||||
|
||||
app.sessionManager.Put(r.Context(), "flash", fmt.Sprintf("LOGGED OUT USER %s! (not really)", id))
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ func (app *application) routes() http.Handler {
|
||||
router.Handler(http.MethodPost, "/user/signup", dynamic.ThenFunc(app.userSignupPost))
|
||||
router.Handler(http.MethodGet, "/user/login", dynamic.ThenFunc(app.userLogin))
|
||||
router.Handler(http.MethodPost, "/user/login", dynamic.ThenFunc(app.userLoginPost))
|
||||
router.Handler(http.MethodPost, "/user/logout", dynamic.ThenFunc(app.userLogoutPost))
|
||||
|
||||
standard := alice.New(app.recoverPanic, app.logRequest, secureHeaders)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user