优化结构
This commit is contained in:
@@ -152,7 +152,12 @@ func (uc *AuthenticationUsecase) Login(ctx context.Context, attempt *LoginAttemp
|
||||
return nil, fmt.Errorf("%w: %v", ErrLoginState, cacheErr)
|
||||
}
|
||||
}
|
||||
return &AuthenticationResult{User: user, Token: issued.Value, ExpiresAt: issued.ExpiresAt, NeedChangePassword: user.MustChangePassword}, nil
|
||||
// AuthenticationResult crosses the biz/service boundary; never retain the
|
||||
// credential hash in the user object returned to transport code. Keep the
|
||||
// repository-owned value untouched in case another caller shares it.
|
||||
resultUser := *user
|
||||
resultUser.Password = ""
|
||||
return &AuthenticationResult{User: &resultUser, Token: issued.Value, ExpiresAt: issued.ExpiresAt, NeedChangePassword: resultUser.MustChangePassword}, nil
|
||||
}
|
||||
|
||||
func userHasAuthority(user *User, authorityID uint) bool {
|
||||
|
||||
Reference in New Issue
Block a user