Skip to content

Commit

Permalink
Send proper HTTP status code if cookies have issues (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodangelis authored Mar 12, 2022
1 parent 6153f25 commit 01a36c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ func New(cfg *config.Config) (*Server, error) {
} else {
// Check for the expected cookie and value
// If it is missing or doesn't match
// return a 404 status
// return a 400 status
rcookie, err := r.Cookie(cookie.Name)
if err != nil || rcookie.Value != cookie.Value {
http.Error(w, "", http.StatusNotFound)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if rcookie.Value != cookie.Value {
http.Error(w, "mismatching cookie", http.StatusBadRequest)
return
}
// If the cookie exits and matches
Expand Down

0 comments on commit 01a36c4

Please sign in to comment.