From 7d2766c4d32da7dcc745f8e795b5910db08c670c Mon Sep 17 00:00:00 2001
From: L4168 <L4168@student.jamk.fi>
Date: Mon, 15 Jul 2019 12:19:48 +0300
Subject: [PATCH] updated verifyFaction service

---
 src/faction/faction.service.ts | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/faction/faction.service.ts b/src/faction/faction.service.ts
index 287b434..3681a94 100644
--- a/src/faction/faction.service.ts
+++ b/src/faction/faction.service.ts
@@ -156,16 +156,14 @@ export class FactionService {
       where: { person, game },
       relations: ['faction'],
     });
-    if (gameperson.faction) {
+    if (gameperson && gameperson.faction) {
       return {
         factionId: gameperson.faction.factionId,
         factionName: gameperson.faction.factionName,
+        role: gameperson.role,
       };
     } else {
-      throw new HttpException(
-        gameperson ? 'You are admin for this game!' : 'No faction was found',
-        HttpStatus.BAD_REQUEST,
-      );
+      return gameperson ? { role: gameperson.role } : { role: '' };
     }
   }
 }
-- 
GitLab