Documentation ¶
Index ¶
- Constants
- Variables
- func GetAcceptedLanguagesFromCtx(ctx *gin.Context) []string
- func GetFromCtx(ctx *gin.Context) *common.User
- func GetLanguagesFromCtx(ctx *gin.Context) []string
- func GetProfileFromCtx(ctx *gin.Context) *common.Profile
- func GetProfilesFromCtx(ctx *gin.Context) []common.Profile
- func GetRolesFromCtx(ctx *gin.Context) []string
- func ValidateAccess[k comparable](ctx context.Context, ...) error
- type CheckConditions
Constants ¶
View Source
const ( RolePublic = "public" RoleRegistered = "registered" RoleBCCMember = "bcc-members" RoleNonBCCMember = "non-bcc-members" )
All well-known roles as used in the DB
View Source
const ( CtxUser = "ctx-user" CacheRoles = "roles" CtxLanguages = "ctx-languages" CtxImpersonating = "ctx-impersonating" CtxProfiles = "ctx-profiles" CtxProfile = "ctx-profile" )
Various hardcoded keys
View Source
const CtxRoles = "roles"
CtxRoles context key for roles
Variables ¶
View Source
var ( ErrItemNotPublished = common.ErrItemNotPublished ErrItemNoAccess = common.ErrItemNoAccess ErrPublishDateInFuture = merry.Sentinel("Publish date in the future") )
Sentinel errors
View Source
var AgeGroups = map[int]string{
65: "65+",
51: "51 - 64",
37: "37 - 50",
26: "26 - 36",
19: "19 - 25",
13: "13 - 18",
10: "10 - 12",
0: "0 - 9",
}
AgeGroups contains the different age groups keyed by the minimum age.
Functions ¶
func GetAcceptedLanguagesFromCtx ¶
GetAcceptedLanguagesFromCtx as sent by the user
func GetFromCtx ¶
GetFromCtx gets the user stored in the context by the middleware
func GetLanguagesFromCtx ¶
GetLanguagesFromCtx as provided in the request
func GetProfileFromCtx ¶
GetProfileFromCtx returns the current profile
func GetProfilesFromCtx ¶
GetProfilesFromCtx returns the current profile
func GetRolesFromCtx ¶
GetRolesFromCtx returns the roles stored in context
func ValidateAccess ¶
func ValidateAccess[k comparable]( ctx context.Context, permissionLoader *loaders.Loader[k, *common.Permissions[k]], id k, conditions CheckConditions, ) error
ValidateAccess returns error if user in context does not have access to the specified item
Types ¶
type CheckConditions ¶
CheckConditions defines which conditions that should be checked
Click to show internal directories.
Click to hide internal directories.