mirror of https://gitee.com/answerdev/answer.git
refactor(role): rename remove user tokens function
This commit is contained in:
parent
15d73ea7a5
commit
f3e5244c40
|
@ -147,8 +147,8 @@ func (ar *authRepo) AddUserTokenMapping(ctx context.Context, userID, accessToken
|
|||
return ar.data.Cache.SetString(ctx, key, string(content), constant.UserTokenCacheTime)
|
||||
}
|
||||
|
||||
// RemoveAllUserTokens Log out all users under this user id
|
||||
func (ar *authRepo) RemoveAllUserTokens(ctx context.Context, userID string) {
|
||||
// RemoveUserTokens Log out all users under this user id
|
||||
func (ar *authRepo) RemoveUserTokens(ctx context.Context, userID string) {
|
||||
key := constant.UserTokenMappingCacheKey + userID
|
||||
resp, _ := ar.data.Cache.GetString(ctx, key)
|
||||
mapping := make(map[string]bool, 0)
|
||||
|
|
|
@ -20,7 +20,7 @@ type AuthRepo interface {
|
|||
SetAdminUserCacheInfo(ctx context.Context, accessToken string, userInfo *entity.UserCacheInfo) error
|
||||
RemoveAdminUserCacheInfo(ctx context.Context, accessToken string) (err error)
|
||||
AddUserTokenMapping(ctx context.Context, userID, accessToken string) (err error)
|
||||
RemoveAllUserTokens(ctx context.Context, userID string)
|
||||
RemoveUserTokens(ctx context.Context, userID string)
|
||||
}
|
||||
|
||||
// AuthService kit service
|
||||
|
@ -85,9 +85,9 @@ func (as *AuthService) AddUserTokenMapping(ctx context.Context, userID, accessTo
|
|||
return as.authRepo.AddUserTokenMapping(ctx, userID, accessToken)
|
||||
}
|
||||
|
||||
// RemoveAllUserTokens Log out all users under this user id
|
||||
func (as *AuthService) RemoveAllUserTokens(ctx context.Context, userID string) {
|
||||
as.authRepo.RemoveAllUserTokens(ctx, userID)
|
||||
// RemoveUserTokens Log out all users under this user id
|
||||
func (as *AuthService) RemoveUserTokens(ctx context.Context, userID string) {
|
||||
as.authRepo.RemoveUserTokens(ctx, userID)
|
||||
}
|
||||
|
||||
//Admin
|
||||
|
|
|
@ -116,7 +116,7 @@ func (us *UserAdminService) UpdateUserRole(ctx context.Context, req *schema.Upda
|
|||
return err
|
||||
}
|
||||
|
||||
us.authService.RemoveAllUserTokens(ctx, req.UserID)
|
||||
us.authService.RemoveUserTokens(ctx, req.UserID)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ func (us *UserAdminService) UpdateUserPassword(ctx context.Context, req *schema.
|
|||
return err
|
||||
}
|
||||
// logout this user
|
||||
us.authService.RemoveAllUserTokens(ctx, req.UserID)
|
||||
us.authService.RemoveUserTokens(ctx, req.UserID)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue