Skip to content
Snippets Groups Projects
Commit 9103c176 authored by Etienne LOUPIAS's avatar Etienne LOUPIAS
Browse files

Merge branch '261-fiche-structure-suppression-connecte-en-admin-impossible' into 'dev'

Resolve "[Fiche structure] - Suppression connecté en admin impossible"

See merge request !276
parents 33381037 a69939f8
No related branches found
No related tags found
2 merge requests!277V2.2.0,!276Resolve "[Fiche structure] - Suppression connecté en admin impossible"
......@@ -25,6 +25,7 @@ import { ITempUser } from '../temp-user/temp-user.interface';
import { TempUser } from '../temp-user/temp-user.schema';
import { TempUserService } from '../temp-user/temp-user.service';
import { Roles } from '../users/decorators/roles.decorator';
import { UserRole } from '../users/enum/user-role.enum';
import { IsStructureOwnerGuard } from '../users/guards/isStructureOwner.guard';
import { RolesGuard } from '../users/guards/roles.guard';
import { pendingStructuresLink } from '../users/interfaces/pendingStructure';
......@@ -204,10 +205,10 @@ export class StructuresController {
const otherOwners: IUser[] = (await this.userService.getStructureOwners(id)).filter((owner) => {
return !owner._id.equals(req.user._id);
});
if (otherOwners.length) {
return this.structureService.setToBeDeleted(req.user, structure);
} else {
if (otherOwners.length === 0 || req.user.role === UserRole.admin) {
return this.structureService.deleteOne(structure);
} else {
return this.structureService.setToBeDeleted(req.user, structure);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment