MCPcopy Index your code
hub / github.com/apache/answer / AddUserTokenMapping

Method AddUserTokenMapping

internal/repo/auth/auth.go:195–208  ·  view source on GitHub ↗

AddUserTokenMapping add user token mapping

(ctx context.Context, userID, accessToken string)

Source from the content-addressed store, hash-verified

193
194// AddUserTokenMapping add user token mapping
195func (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
211func (ar *authRepo) RemoveUserTokens(ctx context.Context, userID string, remainToken string) {

Callers 1

SetUserCacheInfoMethod · 0.95

Calls 2

GetStringMethod · 0.80
SetStringMethod · 0.80

Tested by

no test coverage detected