mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 10:08:21 +00:00
fix issue
This commit is contained in:
@@ -195,15 +195,16 @@ export class RatesService {
|
||||
}
|
||||
|
||||
/** CEO approves a rate — moves to LIVE. */
|
||||
async approve(id: string, approverUserId: string): Promise<Rate> {
|
||||
async approve(id: string, approverUserId: string, canSelfApprove = false): Promise<Rate> {
|
||||
const rate = await this.findById(id);
|
||||
if (rate.status !== 'PENDING_APPROVAL') {
|
||||
throw new BadRequestException('Only PENDING_APPROVAL rates can be approved');
|
||||
}
|
||||
// Separation of duties: the proposer cannot approve their own rate.
|
||||
// TODO: split approval into a distinct CEO/approver permission — a proposer
|
||||
// who also holds the approve permission is still the wrong person to sign off.
|
||||
if (approverUserId === rate.proposedByStaffId) {
|
||||
// Separation of duties: the proposer cannot approve their own rate — except
|
||||
// super admins, who have full backoffice authority (propose + approve).
|
||||
// TODO: split approval into a distinct CEO/approver permission — a normal
|
||||
// proposer who also holds the approve permission is still the wrong signer.
|
||||
if (!canSelfApprove && approverUserId === rate.proposedByStaffId) {
|
||||
throw new ForbiddenException('You cannot approve a rate you proposed');
|
||||
}
|
||||
const updated = await this.repository.update(id, {
|
||||
|
||||
Reference in New Issue
Block a user