优化
This commit is contained in:
@@ -111,6 +111,10 @@ func (uc *AuthenticationUsecase) Login(ctx context.Context, attempt *LoginAttemp
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: %v", ErrTokenIssue, err)
|
||||
}
|
||||
// Record a successful credential login immediately after issuing the JWT.
|
||||
// Multipoint-session persistence happens afterwards, so a Redis/cache
|
||||
// failure must not erase the successful-login audit event.
|
||||
uc.recordLogin(ctx, attempt, true, "登录成功", user.ID)
|
||||
if uc.security.UseMultipoint() {
|
||||
oldToken, cacheErr := uc.security.ActiveToken(ctx, user.Username)
|
||||
if cacheErr != nil {
|
||||
@@ -123,7 +127,6 @@ func (uc *AuthenticationUsecase) Login(ctx context.Context, attempt *LoginAttemp
|
||||
return nil, fmt.Errorf("%w: %v", ErrLoginState, cacheErr)
|
||||
}
|
||||
}
|
||||
uc.recordLogin(ctx, attempt, true, "登录成功", user.ID)
|
||||
return &AuthenticationResult{User: user, Token: issued.Value, ExpiresAt: issued.ExpiresAt, NeedChangePassword: user.MustChangePassword}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user