GetUserID returns the user id which was previously registered by RegisterAuthentication.
(ctx *gin.Context)
| 14 | |
| 15 | // GetUserID returns the user id which was previously registered by RegisterAuthentication. |
| 16 | func GetUserID(ctx *gin.Context) uint { |
| 17 | id := TryGetUserID(ctx) |
| 18 | if id == nil { |
| 19 | panic("token and user may not be null") |
| 20 | } |
| 21 | return *id |
| 22 | } |
| 23 | |
| 24 | // TryGetUserID returns the user id or nil if one is not set. |
| 25 | func TryGetUserID(ctx *gin.Context) *uint { |
searching dependent graphs…