1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Improve user API responses

This commit is contained in:
Frédéric Guillot 2017-12-29 13:53:02 -08:00
parent 7c19febd73
commit 0f053b07a5
3 changed files with 51 additions and 63 deletions

View file

@ -39,7 +39,14 @@ func (b *BasicAuthMiddleware) Handler(next http.Handler) http.Handler {
}
user, err := b.store.UserByUsername(username)
if err != nil || user == nil {
if err != nil {
logger.Error("[Middleware:BasicAuth] %v", err)
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(errorResponse))
return
}
if user == nil {
logger.Info("[Middleware:BasicAuth] User not found: %s", username)
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte(errorResponse))