HandleLogout deletes the session and clears the cookie.
(w http.ResponseWriter, r *http.Request)
| 432 | |
| 433 | // HandleLogout deletes the session and clears the cookie. |
| 434 | func (ua *UserAuth) HandleLogout(w http.ResponseWriter, r *http.Request) { |
| 435 | cookie, err := r.Cookie(SessionCookieName) |
| 436 | if err == nil { |
| 437 | ua.store.DeleteUserSession(r.Context(), cookie.Value) |
| 438 | } |
| 439 | |
| 440 | http.SetCookie(w, &http.Cookie{ |
| 441 | Name: SessionCookieName, |
| 442 | Value: "", |
| 443 | Path: "/", |
| 444 | HttpOnly: true, |
| 445 | Secure: ua.secure, |
| 446 | SameSite: http.SameSiteLaxMode, |
| 447 | MaxAge: -1, |
| 448 | }) |
| 449 | |
| 450 | w.WriteHeader(http.StatusOK) |
| 451 | } |
| 452 | |
| 453 | // HandleMe returns the current authenticated user's info. |
| 454 | func (ua *UserAuth) HandleMe(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected