refactor(role): rename remove user tokens function

This commit is contained in:
LinkinStar 2023-03-26 17:22:00 +08:00
parent 15d73ea7a5
commit f3e5244c40
3 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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
}