Interface: PermissionGuardOptions<R>
Defined in: packages/trpc/src/guards.ts:104
The options every guard takes: the handlers plus guard.
guard is per guard only (like spatie's role:admin,api), not a createGuards() default: the subject's guard comes from createRbacContext() (or resolve). With per-guard names, tell the types which guard the subjects have with createGuards<AppRbac, 'api'>().
Extends
Type Parameters
| Type Parameter | Default type |
|---|---|
R | SubjectRbac |
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
any? | boolean | Pass when the subject has ANY of the permissions (instead of all). Default: false. | - | packages/trpc/src/guards.ts:106 |
exposeRequirements? | boolean | Include the required roles/permissions in the default error (required in its body). Default: false (like spatie's display_permission_in_exception). | RouteGuardOptions.exposeRequirements | packages/trpc/src/guards.ts:71 |
guard? | string | Check in this guard instead of the subject's (subject.withScope({ guard })), like spatie's role:admin,api. Default: the guard of the subject. | RoleGuardOptions.guard | packages/trpc/src/guards.ts:101 |
onForbidden? | GuardHandler<R> | Called when the subject lacks access. Default: a TRPCError FORBIDDEN. | RouteGuardOptions.onForbidden | packages/trpc/src/guards.ts:66 |
onUnauthenticated? | GuardHandler<R> | Called when there is no subject (ctx.rbac is null). Default: a TRPCError UNAUTHORIZED. | RouteGuardOptions.onUnauthenticated | packages/trpc/src/guards.ts:64 |
