update auth

This commit is contained in:
2025-11-24 16:08:16 +03:30
parent e79040d81e
commit 9996ea3b09
8 changed files with 91 additions and 366 deletions
+4 -2
View File
@@ -28,7 +28,7 @@ export class AdminService {
async findById(adminId: string, restId: string): Promise<Admin | null> {
const admin = await this.adminRepository.findOne(
{ id: adminId, roles: { restaurant: { id: restId } } },
{ populate: ['roles', 'roles.role'], distinct: true },
{ populate: ['roles', 'roles.role'] },
);
return admin;
}
@@ -131,7 +131,7 @@ export class AdminService {
}
// Update role if roleId is provided
if (roleId) {
if (roleId ) {
const role = await this.em.findOne(Role, { id: roleId });
if (!role) {
throw new NotFoundException('Role not found');
@@ -147,6 +147,8 @@ export class AdminService {
// Update existing role
existingAdminRole.role = role;
} else {
const restaurant = await this.em.findOne(Restaurant, { id: restId });
if (!restaurant) throw new NotFoundException('Restaurant not found');
// Create new AdminRole
const newAdminRole = this.em.create(AdminRole, {
admin,