more sensible error handling: auth failure

This commit is contained in:
2023-01-07 17:47:18 +01:00
parent 7bf92a6241
commit 285ea8438e
2 changed files with 10 additions and 2 deletions

View File

@@ -189,6 +189,12 @@ func authenticatedRequest(request func(ctx *fasthttp.RequestCtx)) func(ctx *fast
}
authenticated, err := auth.IsPasswordAuthenticated(authRequest)
if err != nil && !authenticated {
ctx.WriteString("Authentication failed: " + err.Error())
ctx.SetStatusCode(fasthttp.StatusForbidden)
return
}
if err != nil {
ctx.WriteString("Internal server error")
ctx.SetStatusCode(fasthttp.StatusInternalServerError)