feat: completed additional privilege factory

This commit is contained in:
=
2025-10-09 23:58:09 +05:30
parent a846831b26
commit c5f2a74d5a
12 changed files with 656 additions and 1 deletions
+7 -1
View File
@@ -44,11 +44,17 @@ export const roleServiceFactory = ({ roleDAL, permissionService }: TRoleServiceF
const factory = scopeFactory[scopeData.scope];
await factory.onCreateRoleGuard(dto);
const scope = factory.getScopeField(scopeData);
const existingRole = await roleDAL.findOne({
slug: data.slug,
[scope.key]: scope.value
});
if (existingRole) throw new NotFoundError({ message: `Role with ${data.slug} exist` });
validateHandlebarTemplate("Role Creation", JSON.stringify(data.permissions || []), {
allowedExpressions: (val) => val.includes("identity.")
});
const scope = factory.getScopeField(scopeData);
const role = await roleDAL.create({
name: data.name,
description: data.description,