~bigbes/core-go

e559510fc24476518e3c39b4ece21335d2facd79 — Drew DeVault 1 year, 9 months ago bdf079e
auth: reduce scope of user_type
1 files changed, 8 insertions(+), 12 deletions(-)

M auth/middleware.go
M auth/middleware.go => auth/middleware.go +8 -12
@@ 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)