From e559510fc24476518e3c39b4ece21335d2facd79 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 13 Nov 2024 14:51:59 +0100 Subject: [PATCH] auth: reduce scope of user_type --- auth/middleware.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/auth/middleware.go b/auth/middleware.go index 4f1de80b46c95e43984c631c2a38d6dab89da36a..fb4b235df5afe74ea504c557b66594945a0ac950 100644 --- a/auth/middleware.go +++ b/auth/middleware.go @@ -38,14 +38,10 @@ var ( ) const ( - USER_UNCONFIRMED = "UNCONFIRMED" - USER_ACTIVE_NON_PAYING = "ACTIVE_NON_PAYING" - USER_ACTIVE_FREE = "ACTIVE_FREE" - USER_ACTIVE_PAYING = "ACTIVE_PAYING" - USER_ACTIVE_DELINQUENT = "ACTIVE_DELINQUENT" - USER_ADMIN = "ADMIN" - USER_UNKNOWN = "UNKNOWN" - USER_SUSPENDED = "SUSPENDED" + USER_TYPE_PENDING = "UNCONFIRMED" + USER_TYPE_USER = "ACTIVE_NON_PAYING" + USER_TYPE_ADMIN = "ADMIN" + USER_TYPE_SUSPENDED = "SUSPENDED" ) const ( @@ -132,7 +128,7 @@ func authForUsername(ctx context.Context, username string) (*AuthContext, error) return nil, err } - if auth.UserType == USER_SUSPENDED { + if auth.UserType == USER_TYPE_SUSPENDED { return nil, fmt.Errorf( "Account suspended with the following notice: %s\nContact support", *auth.SuspensionNotice) @@ -193,7 +189,7 @@ func authForOAuthClient(ctx context.Context, clientUUID string) (*AuthContext, e return nil, err } - if auth.UserType == USER_SUSPENDED { + if auth.UserType == USER_TYPE_SUSPENDED { return nil, fmt.Errorf( "Account suspended with the following notice: %s\nContact support", *auth.SuspensionNotice) @@ -555,7 +551,7 @@ func OAuth2(token string, hash [64]byte, w http.ResponseWriter, return } - if auth.UserType == USER_SUSPENDED { + if auth.UserType == USER_TYPE_SUSPENDED { authError(w, fmt.Sprintf( "Account suspended with the following notice: %s\nContact support", *auth.SuspensionNotice), http.StatusForbidden) @@ -644,7 +640,7 @@ func LegacyOAuth(bearer string, hash [64]byte, w http.ResponseWriter, return } - if auth.UserType == USER_SUSPENDED { + if auth.UserType == USER_TYPE_SUSPENDED { authError(w, fmt.Sprintf( "Account suspended with the following notice: %s\nContact support", *auth.SuspensionNotice), http.StatusForbidden)