MCPcopy Create free account
hub / github.com/Threadfin/Threadfin / setToken

Function setToken

src/internal/authentication/authentication.go:559–575  ·  view source on GitHub ↗
(id, oldToken string)

Source from the content-addressed store, hash-verified

557}
558
559func setToken(id, oldToken string) (newToken string) {
560 delete(tokens, oldToken)
561
562loopToken:
563 newToken = randomString(tokenLength)
564 if _, ok := tokens[newToken]; ok {
565 goto loopToken
566 }
567
568 var tmp = make(map[string]interface{})
569 tmp["id"] = id
570 tmp["expires"] = time.Now().Local().Add(time.Minute * time.Duration(tokenValidity))
571
572 tokens[newToken] = tmp
573
574 return
575}
576
577func mapToJSON(tmpMap interface{}) string {
578 jsonString, err := json.MarshalIndent(tmpMap, "", " ")

Callers 2

UserAuthenticationFunction · 0.85

Calls 1

randomStringFunction · 0.70

Tested by

no test coverage detected