TryGetUserID returns the user id or nil if one is not set.
(ctx *gin.Context)
| 23 | |
| 24 | // TryGetUserID returns the user id or nil if one is not set. |
| 25 | func 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. |
| 39 | func GetTokenID(ctx *gin.Context) string { |
no outgoing calls
searching dependent graphs…