AddUserTokenMapping add user token mapping
(ctx context.Context, userID, accessToken string)
| 193 | |
| 194 | // AddUserTokenMapping add user token mapping |
| 195 | func (ar *authRepo) AddUserTokenMapping(ctx context.Context, userID, accessToken string) (err error) { |
| 196 | key := constant.UserTokenMappingCacheKey + userID |
| 197 | resp, _, err := ar.data.Cache.GetString(ctx, key) |
| 198 | if err != nil { |
| 199 | return err |
| 200 | } |
| 201 | mapping := make(map[string]bool, 0) |
| 202 | if len(resp) > 0 { |
| 203 | _ = json.Unmarshal([]byte(resp), &mapping) |
| 204 | } |
| 205 | mapping[accessToken] = true |
| 206 | content, _ := json.Marshal(mapping) |
| 207 | return ar.data.Cache.SetString(ctx, key, string(content), constant.UserTokenCacheTime) |
| 208 | } |
| 209 | |
| 210 | // RemoveUserTokens Log out all users under this user id |
| 211 | func (ar *authRepo) RemoveUserTokens(ctx context.Context, userID string, remainToken string) { |
no test coverage detected