MCPcopy Index your code
hub / github.com/gotify/server / TryGetUserID

Function TryGetUserID

auth/util.go:25–36  ·  view source on GitHub ↗

TryGetUserID returns the user id or nil if one is not set.

(ctx *gin.Context)

Source from the content-addressed store, hash-verified

23
24// TryGetUserID returns the user id or nil if one is not set.
25func TryGetUserID(ctx *gin.Context) *uint {
26 user := ctx.MustGet("user").(*model.User)
27 if user == nil {
28 userID := ctx.MustGet("userid").(uint)
29 if userID == 0 {
30 return nil
31 }
32 return &userID
33 }
34
35 return &user.ID
36}
37
38// GetTokenID returns the tokenID.
39func GetTokenID(ctx *gin.Context) string {

Callers 4

CreateUserMethod · 0.92
expectTryUserIDWithMethod · 0.85
GetUserIDFunction · 0.85
TestOptionalAuthMethod · 0.85

Calls

no outgoing calls

Tested by 2

expectTryUserIDWithMethod · 0.68
TestOptionalAuthMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…