feat(web): redirect to login on expired cookie (#201)

* feat(web): redirect to login on expired cookie

* refactor: simplify auth wrapper
This commit is contained in:
Ludvig Lundgren 2022-03-26 19:46:16 +01:00 committed by GitHub
parent baac92cc25
commit 2d3ab67604
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 11 deletions

View file

@ -9,7 +9,7 @@ func (s Server) IsAuthenticated(next http.Handler) http.Handler {
// Check if user is authenticated
if auth, ok := session.Values["authenticated"].(bool); !ok || !auth {
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
return
}
next.ServeHTTP(w, r)