context

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// LocaleParameterName localization parameter name.
	LocaleParameterName = "locale"
)

Variables

This section is empty.

Functions

func GetAuthTokenID

func GetAuthTokenID(c *gin.Context) string

GetAuthTokenID : returns the auth token ID.

func GetLocale

func GetLocale(c *gin.Context) string

GetLocale : returns the locale bound to the request.

func GetParsedToken

func GetParsedToken(c *gin.Context) *jwt.Token

GetParsedToken : returns the JWT token.

func GetRequestLocale

func GetRequestLocale(c *gin.Context) string

GetRequestLocale : returns the context locale.

func GetSignedToken

func GetSignedToken(c *gin.Context) string

GetSignedToken : returns the signed token.

func GetUser

func GetUser(c *gin.Context) interface{}

GetUser : returns the user struct.

func GetUserID

func GetUserID(c *gin.Context) string

GetUserID : returns the user ID.

func GetUserLocale

func GetUserLocale(c *gin.Context) string

GetUserLocale : returns the user locale.

func InjectLocale

func InjectLocale(defaultAppLocale string, supportedAppLocales []string) gin.HandlerFunc

InjectLocale saves the current locales to the context.

func ParseAuthToken

func ParseAuthToken(secret string, buildUser GetUserAndLocaleFromAuthTokenFunc, authTokenMustBePresent bool) gin.HandlerFunc

ParseAuthToken : parses and saves the authenticated user to the context.

func RefreshAuthToken

func RefreshAuthToken(c *gin.Context)

RefreshAuthToken : refreshes the auth token with the latest properties of the user.

func VerifyAuthToken

func VerifyAuthToken(verifyToken IsAuthTokenValidFunc) gin.HandlerFunc

VerifyAuthToken : checks the auth token is valid and not expired/revoked.

func VerifyLatestVersionOfTermsAcceptedByUser

func VerifyLatestVersionOfTermsAcceptedByUser(currentTermsVersion string, getLatestVersionOfTermsAcceptedByUser GetLatestVersionOfTermsAcceptedByUserFunc) gin.HandlerFunc

VerifyLatestVersionOfTermsAcceptedByUser : checks and saves the authenticated user to the context.

Types

type GetLatestVersionOfTermsAcceptedByUserFunc

type GetLatestVersionOfTermsAcceptedByUserFunc func(c *gin.Context, userID string) string

GetLatestVersionOfTermsAcceptedByUserFunc : returns the latest version of the terms accepted by the user.

type GetUserAndLocaleFromAuthTokenFunc

type GetUserAndLocaleFromAuthTokenFunc func(token *jwt.Token) (interface{}, string)

GetUserAndLocaleFromAuthTokenFunc : returns a struct represnting the user and its loale from an auth token.

type IsAuthTokenValidFunc

type IsAuthTokenValidFunc func(c *gin.Context, tokenID string) bool

IsAuthTokenValidFunc : returns trus if the auth token is still valid and not expired or revoked.

Jump to

Keyboard shortcuts

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