fix: update tariff privilege check remove
This commit is contained in:
parent
4355698db8
commit
adcb57f157
@ -108,16 +108,9 @@ export const replaceTariff = async (request: ReplaceTariffRequest, reply: Fastif
|
||||
throw new Error("tariff not found");
|
||||
}
|
||||
|
||||
for (const privilege of requestBody.privileges) {
|
||||
if (!Types.ObjectId.isValid(privilege.privilegeId)) {
|
||||
void reply.status(404);
|
||||
throw new Error(`privilege id <${privilege.privilegeId}> invalid`);
|
||||
}
|
||||
}
|
||||
|
||||
const privilegesMap = new Map(requestBody.privileges.map((privilege) => [privilege.privilegeId, privilege]));
|
||||
const privilegeIDs = requestBody.privileges.map(({ privilegeId }) => privilegeId);
|
||||
const privileges = await PrivilegeModel.find({ _id: privilegeIDs }).lean();
|
||||
const privileges = await PrivilegeModel.find({ privilegeId: privilegeIDs }).lean();
|
||||
|
||||
const cleanPrivileges = privileges.map<Omit<Privilege, keyof Eloquent>>((privilege) => {
|
||||
const currentPrivilege = privilegesMap.get(privilege._id.toString());
|
||||
|
Loading…
Reference in New Issue
Block a user