Skip to content

Commit

Permalink
feat: improve error message when no session is found (ory#2988)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Dec 27, 2022
1 parent d3dad4a commit c15f19d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions session/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ func RespondWithJSONErrorOnAuthenticated(h herodot.Writer, err error) httprouter
h.WriteError(w, r, err)
}
}

var ErrNoSessionFound = herodot.ErrUnauthorized.WithReasonf("No valid session credentials found in the request.")
4 changes: 2 additions & 2 deletions session/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ func (h *Handler) whoami(w http.ResponseWriter, r *http.Request, ps httprouter.P
w.Header().Set("Ory-Session-Cache-For", fmt.Sprintf("%d", int64(time.Minute.Seconds())))
}

h.r.Audit().WithRequest(r).WithError(err).Info("No valid session cookie found.")
h.r.Writer().WriteError(w, r, herodot.ErrUnauthorized.WithWrap(err).WithReasonf("No valid session cookie found."))
h.r.Audit().WithRequest(r).WithError(err).Info("No valid session found.")
h.r.Writer().WriteError(w, r, ErrNoSessionFound.WithWrap(err))
return
}

Expand Down

0 comments on commit c15f19d

Please sign in to comment.