From ea0bf7bf698486cda875113852d6cc5c957f1f55 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Fri, 9 Apr 2021 11:12:27 +0200
Subject: [PATCH] fix(structures): prevent access to deleted structures

---
 src/structures/structures.controller.ts | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/structures/structures.controller.ts b/src/structures/structures.controller.ts
index 96ed9e332..67e12c9a1 100644
--- a/src/structures/structures.controller.ts
+++ b/src/structures/structures.controller.ts
@@ -120,7 +120,12 @@ export class StructuresController {
 
   @Get(':id')
   public async find(@Param('id') id: string) {
-    return this.structureService.findOne(id);
+    const result = await this.structureService.findOne(id);
+    if (!result || result.deletedAt) {
+      throw new HttpException('Structure does not exist', HttpStatus.NOT_FOUND);
+    } else {
+      return result;
+    }
   }
 
   @Post(':id/withOwners')
-- 
GitLab