Skip to content

Commit 78e1e9e

Browse files
committed
chore: leverage early return
1 parent 7c042cd commit 78e1e9e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

api/auth.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ func (a *API) authMiddleware(next http.Handler) http.Handler {
2727
Error("failed to authenticate")
2828
types.NewUnauthorizedError(err).JSON(w)
2929
return
30-
} else if !strings.HasPrefix(token, "Bearer ") {
30+
}
31+
32+
if !strings.HasPrefix(token, "Bearer ") {
3133
err := errors.New("authorization header must start with Bearer ")
3234
a.logger.WithFields(logrusFieldsFromRequest(r)).WithError(err).
3335
Error("failed to authenticate")
@@ -63,7 +65,9 @@ func (a *API) postAuthLogin(w http.ResponseWriter, r *http.Request) {
6365
if errors.Is(err, auth.ErrInvalidPassword) {
6466
types.NewUnauthorizedError(err).JSON(w)
6567
return
66-
} else if err != nil {
68+
}
69+
70+
if err != nil {
6771
a.logger.WithFields(logrusFieldsFromRequest(r)).WithError(err).
6872
Error("failed to authenticate")
6973
types.NewInternalServerError(err).JSON(w)

0 commit comments

Comments
 (0)