Documentation
¶
Index ¶
Constants ¶
View Source
const (
UserContextKey contextKey = iota // iota increments automatically, userContextKey will be 0
)
Declare constants for the keys using the custom type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserClaims ¶
type UserClaims struct { jwt.RegisteredClaims // Embedding the standard jwt claims AccessLevel int `json:"access_level"` // User access level Email string `json:"email"` // User's email address Timestamp int64 `json:"timestamp"` // The timestamp when the JWT was issued UserID int `json:"user_id"` // Unique identifier for the user }
UserClaims defines the structure of the JWT claims used in the application.
func GetUserFromContext ¶
func GetUserFromContext(ctx context.Context) (*UserClaims, error)
GetUserFromContext retrieves the user claims from the context. It returns an error if the user claims cannot be found or are of the wrong type.
Click to show internal directories.
Click to hide internal directories.