Skip to content

Commit

Permalink
users: Return non-successful status code when failing auth. (#123)
Browse files Browse the repository at this point in the history
Because `writeJson()` was returning a 200, it made errors look as if
they were successful, which was throwing off logic in the frontend app.
This makes any failure return a 400 code.
  • Loading branch information
richardxia authored Jun 27, 2024
1 parent 2262874 commit 43e039e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions internal/users/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func New(dbManager *db.Manager, jwtKeyfunc keyfunc.Keyfunc) *Manager {
func (m *Manager) GetCurrent(w http.ResponseWriter, r *http.Request) {
dbUser, err := auth.GetUserFromRequest(r, m.JwtKeyfunc, m.DbClient)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
writeJson(w, ApiError{err.Error()})
return
}
Expand Down

0 comments on commit 43e039e

Please sign in to comment.