replace static status definition by const

This commit is contained in:
venture
2026-11-14 09:57:52 +01:00
parent 276a9fe320
commit f16363cb60
10 changed files with 65 additions and 48 deletions
+6 -5
View File
@@ -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
}