up
This commit is contained in:
@@ -21,15 +21,27 @@ export class AdminRepository extends EntityRepository<Admin> {
|
||||
}
|
||||
|
||||
// Find AdminRole that matches the admin phone and restaurant
|
||||
const adminRole = await this.em.findOne(AdminRole, {
|
||||
admin: { phone },
|
||||
restaurant: { id: restaurant.id },
|
||||
});
|
||||
const adminRole = await this.em.findOne(
|
||||
AdminRole,
|
||||
{
|
||||
admin: { phone },
|
||||
restaurant: { id: restaurant.id },
|
||||
},
|
||||
{ populate: ['admin', 'admin.roles', 'role', 'role.permissions', 'restaurant'] },
|
||||
);
|
||||
|
||||
if (!adminRole || !adminRole.admin) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ensure all roles are populated
|
||||
await adminRole.admin.roles.loadItems();
|
||||
for (const role of adminRole.admin.roles.getItems()) {
|
||||
if (role.role && !role.role.permissions.isInitialized()) {
|
||||
await role.role.permissions.loadItems();
|
||||
}
|
||||
}
|
||||
|
||||
return adminRole.admin;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user