This commit is contained in:
2026-08-14 16:34:17 +08:00
parent e0b0e1d8c8
commit f63acae353
53 changed files with 2488 additions and 350 deletions
+6 -1
View File
@@ -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