feat(api/orders): add validation to prevent masters from recording other masters as clients
This commit is contained in:
parent
1e4e4aa336
commit
686fe60b80
@ -67,6 +67,15 @@ export class OrdersService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
if (isMaster) {
|
||||
const { customers: myMasters } = await customersService.getMasters(this.customer);
|
||||
|
||||
const clientId = variables.input.client;
|
||||
const isTryingToRecordMaster = myMasters.some((master) => master?.documentId === clientId);
|
||||
|
||||
if (isTryingToRecordMaster) throw new Error(ERRORS.INVALID_CLIENT);
|
||||
}
|
||||
|
||||
if (isMaster && slot?.master?.documentId !== customer.documentId) {
|
||||
throw new Error(ERRORS.INVALID_MASTER);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user