replace static status definition by const
This commit is contained in:
+6
-5
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"mediarr/database"
|
||||
"mediarr/ident"
|
||||
"mediarr/identity"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -57,7 +58,7 @@ func (s *Service) CreateSession(ctx context.Context, params CreateSessionParams)
|
||||
}
|
||||
return nil, "", err
|
||||
}
|
||||
if principal.Status != "active" {
|
||||
if principal.Status != identity.StatusActive {
|
||||
return nil, "", ErrInvalidSession
|
||||
}
|
||||
|
||||
@@ -67,10 +68,10 @@ func (s *Service) CreateSession(ctx context.Context, params CreateSessionParams)
|
||||
switch {
|
||||
case err == nil:
|
||||
switch account.State {
|
||||
case "active":
|
||||
case "disabled":
|
||||
case AccountStateActive:
|
||||
case AccountStateDisabled:
|
||||
return nil, "", ErrAccountDisabled
|
||||
case "locked":
|
||||
case AccountStateLocked:
|
||||
if !account.LockedUntil.Valid || account.LockedUntil.Int64 > now {
|
||||
return nil, "", ErrAccountLocked
|
||||
}
|
||||
@@ -152,7 +153,7 @@ func (s *Service) ValidateSession(ctx context.Context, token string) (*Session,
|
||||
}
|
||||
return nil, nil, err
|
||||
}
|
||||
if user.Principal.Status != "active" || user.Account.State == "disabled" {
|
||||
if user.Principal.Status != identity.StatusActive || user.Account.State == AccountStateDisabled {
|
||||
return nil, nil, ErrInvalidSession
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user