set header code when sessionstore returns err

This commit is contained in:
Danny 2018-05-15 14:20:05 +02:00
parent 47c6dc3ab7
commit 0039683b74
1 changed files with 3 additions and 0 deletions

View File

@ -66,7 +66,10 @@ func (api *API) LogoutHandler(w http.ResponseWriter, r *http.Request) error {
func (api *API) Authorize(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
session, err := api.sessions.Get(r, "auth")
// an err is returned if cookie has been tampered with, so check that
if err != nil {
w.WriteHeader(http.StatusUnauthorized)
return
}