fix
This commit is contained in:
@@ -8,6 +8,11 @@ import (
|
||||
"kra/pkg/adminauth"
|
||||
)
|
||||
|
||||
type UserDisabledError struct{ UserID uint }
|
||||
|
||||
func (e *UserDisabledError) Error() string { return biz.ErrUserDisabled.Error() }
|
||||
func (e *UserDisabledError) Unwrap() error { return biz.ErrUserDisabled }
|
||||
|
||||
type LoginResult struct {
|
||||
User map[string]any `json:"user"`
|
||||
Token string `json:"token"`
|
||||
@@ -34,7 +39,7 @@ func (s *SystemService) Login(ctx context.Context, username, password string) (*
|
||||
return nil, err
|
||||
}
|
||||
if u.Enable != 1 {
|
||||
return nil, biz.ErrUserDisabled
|
||||
return nil, &UserDisabledError{UserID: u.ID}
|
||||
}
|
||||
if security, securityErr := s.settings.CurrentSecurity(ctx); securityErr == nil && security.PwdExpireEnable && u.PasswordUpdatedAt != nil && time.Since(*u.PasswordUpdatedAt) > time.Duration(security.PwdExpireDays)*24*time.Hour {
|
||||
u.MustChangePassword = true
|
||||
|
||||
Reference in New Issue
Block a user