15 lines
520 B
TypeScript
15 lines
520 B
TypeScript
import { UseGuards, applyDecorators } from '@nestjs/common';
|
|
import { Privilege } from './privilege.decorator';
|
|
import { PrivilegesGuard } from '../guards/privileges.guard';
|
|
import { ApiBearerAuth, ApiForbiddenResponse } from '@nestjs/swagger';
|
|
|
|
export const RequirePrivileges = (...privileges: string[]) =>
|
|
applyDecorators(
|
|
Privilege(...privileges),
|
|
UseGuards(PrivilegesGuard),
|
|
ApiBearerAuth(),
|
|
ApiForbiddenResponse({
|
|
description: `Privileges required: ${privileges.join(' or ')}`,
|
|
}),
|
|
);
|