Class: RbacGuard
Defined in: packages/nestjs/src/guard.ts:42
Resolves the current subject (once per request) and enforces the @RequirePermissions(), @RequireRoles() and @RequireRoleOrPermission() metadata of the class and the handler. A requirement with { guard } is checked in that guard (subject.withScope({ guard })).
- no subject →
UnauthorizedException401 { error: 'UNAUTHENTICATED', message } - missing access →
ForbiddenException403 { error: 'FORBIDDEN', reason, message }
Bodies are identical to @anievo-id/rbac-evolution-express.
Implements
CanActivate
Constructors
Constructor
ts
new RbacGuard(reflector, options): RbacGuard;Defined in: packages/nestjs/src/guard.ts:44
Parameters
| Parameter | Type |
|---|---|
reflector | Reflector |
options | RbacModuleOptions |
Returns
RbacGuard
Methods
canActivate()
ts
canActivate(context): Promise<boolean>;Defined in: packages/nestjs/src/guard.ts:49
Parameters
| Parameter | Type | Description |
|---|---|---|
context | ExecutionContext | Current execution context. Provides access to details about the current request pipeline. |
Returns
Promise<boolean>
Value indicating whether or not the current request is allowed to proceed.
Implementation of
CanActivate.canActivate
