mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
fix(server): premissions guard for read and write endpoints
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { BillPaymentsApplication } from './BillPaymentsApplication.service';
|
||||
import {
|
||||
@@ -26,12 +27,18 @@ import { BillPaymentsPages } from './commands/BillPaymentsPages.service';
|
||||
import { BillPaymentResponseDto } from './dtos/BillPaymentResponse.dto';
|
||||
import { PaginatedResponseDto } from '@/common/dtos/PaginatedResults.dto';
|
||||
import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders';
|
||||
import { RequirePermission } from '@/modules/Roles/RequirePermission.decorator';
|
||||
import { PermissionGuard } from '@/modules/Roles/Permission.guard';
|
||||
import { AuthorizationGuard } from '@/modules/Roles/Authorization.guard';
|
||||
import { AbilitySubject } from '@/modules/Roles/Roles.types';
|
||||
import { IPaymentMadeAction } from './types/BillPayments.types';
|
||||
|
||||
@Controller('bill-payments')
|
||||
@ApiTags('Bill Payments')
|
||||
@ApiExtraModels(BillPaymentResponseDto)
|
||||
@ApiExtraModels(PaginatedResponseDto)
|
||||
@ApiCommonHeaders()
|
||||
@UseGuards(AuthorizationGuard, PermissionGuard)
|
||||
export class BillPaymentsController {
|
||||
constructor(
|
||||
private billPaymentsApplication: BillPaymentsApplication,
|
||||
@@ -39,12 +46,14 @@ export class BillPaymentsController {
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
@RequirePermission(IPaymentMadeAction.Create, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({ summary: 'Create a new bill payment.' })
|
||||
public createBillPayment(@Body() billPaymentDTO: CreateBillPaymentDto) {
|
||||
return this.billPaymentsApplication.createBillPayment(billPaymentDTO);
|
||||
}
|
||||
|
||||
@Delete(':billPaymentId')
|
||||
@RequirePermission(IPaymentMadeAction.Delete, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({ summary: 'Delete the given bill payment.' })
|
||||
@ApiParam({
|
||||
name: 'billPaymentId',
|
||||
@@ -59,6 +68,7 @@ export class BillPaymentsController {
|
||||
}
|
||||
|
||||
@Put(':billPaymentId')
|
||||
@RequirePermission(IPaymentMadeAction.Edit, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({ summary: 'Edit the given bill payment.' })
|
||||
@ApiParam({
|
||||
name: 'billPaymentId',
|
||||
@@ -77,6 +87,7 @@ export class BillPaymentsController {
|
||||
}
|
||||
|
||||
@Get('/new-page/entries')
|
||||
@RequirePermission(IPaymentMadeAction.View, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({
|
||||
summary:
|
||||
'Retrieves the payable entries of the new page once vendor be selected.',
|
||||
@@ -95,6 +106,7 @@ export class BillPaymentsController {
|
||||
}
|
||||
|
||||
@Get(':billPaymentId/bills')
|
||||
@RequirePermission(IPaymentMadeAction.View, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({ summary: 'Retrieves the bills of the given bill payment.' })
|
||||
@ApiParam({
|
||||
name: 'billPaymentId',
|
||||
@@ -107,6 +119,7 @@ export class BillPaymentsController {
|
||||
}
|
||||
|
||||
@Get('/:billPaymentId/edit-page')
|
||||
@RequirePermission(IPaymentMadeAction.View, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({
|
||||
summary: 'Retrieves the edit page of the given bill payment.',
|
||||
})
|
||||
@@ -126,6 +139,7 @@ export class BillPaymentsController {
|
||||
}
|
||||
|
||||
@Get(':billPaymentId')
|
||||
@RequirePermission(IPaymentMadeAction.View, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({ summary: 'Retrieves the bill payment details.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
@@ -145,6 +159,7 @@ export class BillPaymentsController {
|
||||
}
|
||||
|
||||
@Get()
|
||||
@RequirePermission(IPaymentMadeAction.View, AbilitySubject.PaymentMade)
|
||||
@ApiOperation({ summary: 'Retrieves the bill payments list.' })
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
|
||||
Reference in New Issue
Block a user