RemoveUserTokens Log out all users under this user id
(ctx context.Context, userID string, remainToken string)
| 209 | |
| 210 | // RemoveUserTokens Log out all users under this user id |
| 211 | func (ar *authRepo) RemoveUserTokens(ctx context.Context, userID string, remainToken string) { |
| 212 | key := constant.UserTokenMappingCacheKey + userID |
| 213 | resp, _, err := ar.data.Cache.GetString(ctx, key) |
| 214 | if err != nil { |
| 215 | return |
| 216 | } |
| 217 | mapping := make(map[string]bool, 0) |
| 218 | if len(resp) > 0 { |
| 219 | _ = json.Unmarshal([]byte(resp), &mapping) |
| 220 | log.Debugf("find %d user tokens by user id %s", len(mapping), userID) |
| 221 | } |
| 222 | |
| 223 | for token := range mapping { |
| 224 | if token == remainToken { |
| 225 | continue |
| 226 | } |
| 227 | if err := ar.RemoveUserCacheInfo(ctx, token); err != nil { |
| 228 | log.Error(err) |
| 229 | } else { |
| 230 | log.Debugf("del user %s token success", userID) |
| 231 | } |
| 232 | } |
| 233 | if err := ar.RemoveUserStatus(ctx, userID); err != nil { |
| 234 | log.Error(err) |
| 235 | } |
| 236 | if err := ar.data.Cache.Del(ctx, key); err != nil { |
| 237 | log.Error(err) |
| 238 | } |
| 239 | } |
nothing calls this directly
no test coverage detected