Skip to content

HasPermissionProps

Defined in: packages/core/src/access/hasPermission.ts:39

Props required for the hasPermission({…}) function

access

The resolved config from defineAccess(). undefined disables access control entirely — every check passes.

user

The authenticated user document. Roles are derived from user[access.userRolesField] (string or string[]); a missing or empty value falls back to access.anonRole

organization

The organization document forwarded to callbacks. Only surfaces when access.orgCollectionSlug is configured.

resource

Subject name — a resource slug, a built-in subject (e.g. "adminPanel"), or a custom resource name.

action

Action on resource, typed per subject.

data

Document/context forwarded to permission callbacks.

throwOnDenied

When true, throws VexAccessError instead of

scope

Which question to answer when a role’s check is a callback that needs the document and data was not supplied: "all" (default) asks “may they do this to every document” and resolves such a check to false — fail-closed, never throws; "any" asks “may they do this to at least one document” and resolves it to true (nav/sidebar/list gating — row-level filtering happens separately in find/get); "doc" demands an exact per-document answer and throws VexAccessError when data is missing, which is what you want in edit views. Has no effect on static boolean checks, and no effect when data is provided (the callback is always run against it).

"all"

TSubjects extends Record<string, SubjectEntry> = Record<string, SubjectEntry>

TSubject extends keyof TSubjects & string = keyof TSubjects & string

TData extends object = { }

optional access?: VexAccessConfig<TSubjects, readonly AccessResource[], string, string | undefined, Partial<Record<string, CustomActionsInput>>>

Defined in: packages/core/src/access/hasPermission.ts:44


action: TSubjects[TSubject]["action"]

Defined in: packages/core/src/access/hasPermission.ts:48


optional data?: TData

Defined in: packages/core/src/access/hasPermission.ts:49


optional organization?: Record<string, unknown>

Defined in: packages/core/src/access/hasPermission.ts:46


resource: TSubject

Defined in: packages/core/src/access/hasPermission.ts:47


optional scope?: PermissionScope

Defined in: packages/core/src/access/hasPermission.ts:51


optional throwOnDenied?: boolean

Defined in: packages/core/src/access/hasPermission.ts:50


user: Record<string, unknown> | null

Defined in: packages/core/src/access/hasPermission.ts:45