Skip to content

Commit

Permalink
Fix handling of nonexistent user trying to log in
Browse files Browse the repository at this point in the history
  • Loading branch information
eest committed Dec 19, 2024
1 parent 9b2d6d5 commit abb5b9c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ func authMiddleware(dbPool *pgxpool.Pool, logger zerolog.Logger) func(next http.
&argon2TagSize,
)
if err != nil {
if err == pgx.ErrNoRows {
// The user does not exist etc, try again
w.Header().Add("WWW-Authenticate", fmt.Sprintf(`Basic realm="%s"`, realm))
w.WriteHeader(http.StatusUnauthorized)
return
}
logger.Err(err).Msg("failed looking up username for authentication")
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
Expand Down

0 comments on commit abb5b9c

Please sign in to comment.