apptypes

package
v0.0.0-...-9780e12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL