Skip to content

Commit

Permalink
Add more explicit error message when user has not logged in yet
Browse files Browse the repository at this point in the history
  • Loading branch information
oxtyped committed Jul 15, 2024
1 parent e32a127 commit 566505b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/middleware/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ func Verify(key string, noAuth bool) func(http.Handler) http.Handler {

ck, err := r.Cookie("sessionid")
if err != nil {
w.WriteHeader(400)
log.Println(err)
return
if err == http.ErrNoCookie {
log.Printf("missing cookie, have you logged in yet: %#v", err)
w.WriteHeader(401)
return
} else {
w.WriteHeader(400)
log.Printf("error retrieving cookie: %#v", err)
return
}
}

session, err := b64.StdEncoding.DecodeString(ck.Value)
Expand Down

0 comments on commit 566505b

Please sign in to comment.