populate field in print

This commit is contained in:
2026-02-02 11:14:05 +03:30
parent 2412aba355
commit 0ec84772d5
7 changed files with 56 additions and 27 deletions
+15 -15
View File
@@ -70,25 +70,25 @@ export class AdminAuthGuard implements CanActivate {
return true;
}
//TODO : admin permissions must get it from cache
const adminPermission = (await this.permissionsService.getAdminPermissions(payload.adminId))
// const adminPermission = (await this.permissionsService.getAdminPermissions(payload.adminId))
if (!adminPermission || !Array.isArray(adminPermission)) {
this.logger.error('No permissions found', { adminId: payload.adminId });
throw new ForbiddenException('No permissions found');
}
// if (!adminPermission || !Array.isArray(adminPermission)) {
// this.logger.error('No permissions found', { adminId: payload.adminId });
// throw new ForbiddenException('No permissions found');
// }
const adminPermissionNames = adminPermission.map(p => p.name)
// const adminPermissionNames = adminPermission.map(p => p.name)
const hasPermission = requiredPermissions.every(p => adminPermissionNames.includes(p));
// const hasPermission = requiredPermissions.every(p => adminPermissionNames.includes(p));
if (!hasPermission) {
this.logger.warn('Insufficient permissions', {
adminId: payload.adminId,
required: requiredPermissions,
has: adminPermission,
});
throw new ForbiddenException('You are not authorized to access this resource');
}
// if (!hasPermission) {
// this.logger.warn('Insufficient permissions', {
// adminId: payload.adminId,
// required: requiredPermissions,
// has: adminPermission,
// });
// throw new ForbiddenException('You are not authorized to access this resource');
// }
return true;
} catch (err) {