diff --git a/auth/middleware.go b/auth/middleware.go index 771756d91367478a3fd0c1824a5229759e403c30..3fc6051962e8d661d85e860c340dcf9ab65ff507 100644 --- a/auth/middleware.go +++ b/auth/middleware.go @@ -120,13 +120,6 @@ var auth AuthContext if err := LookupUser(ctx, username, &auth); err != nil { return nil, err } - - if auth.UserType == USER_TYPE_SUSPENDED { - return nil, fmt.Errorf( - "Account suspended with the following notice: %s\nContact support", - *auth.SuspensionNotice) - } - return &auth, nil } @@ -212,6 +205,14 @@ auth, err := authForUsername(r.Context(), authCookie.Name) if err != nil { authError(w, err.Error(), http.StatusForbidden) + return + } + + if auth.UserType == USER_TYPE_SUSPENDED { + authError(w, fmt.Sprintf( + "Account suspended with the following notice: %s\nContact support", + *auth.SuspensionNotice), + http.StatusForbidden) return }