update auth
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user