MCPcopy
hub / github.com/dgraph-io/dgraph / ExtractUserName

Function ExtractUserName

x/jwt_helper.go:55–66  ·  view source on GitHub ↗
(jwtToken string)

Source from the content-addressed store, hash-verified

53}
54
55func ExtractUserName(jwtToken string) (string, error) {
56 claims, err := ParseJWT(jwtToken)
57 if err != nil {
58 return "", err
59 }
60 userId, ok := claims["userid"].(string)
61 if !ok {
62 return "", errors.Errorf("userid in claims is not a string:%v", userId)
63 }
64
65 return userId, nil
66}
67
68func ExtractNamespaceFromJwt(jwtToken string) (uint64, error) {
69 claims, err := ParseJWT(jwtToken)

Callers 2

getUserFunction · 0.92
extractNameFunction · 0.92

Calls 2

ParseJWTFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected