From 8763a8795a5248fec343d6b91fdd446f900925d4 Mon Sep 17 00:00:00 2001
From: Ronnie Friman <L4168@student.jamk.fi>
Date: Thu, 18 Jul 2019 20:03:30 +0300
Subject: [PATCH] fix group create bug

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

diff --git a/src/faction/faction.service.ts b/src/faction/faction.service.ts
index bcaf4af..4a574ba 100644
--- a/src/faction/faction.service.ts
+++ b/src/faction/faction.service.ts
@@ -102,12 +102,11 @@ export class FactionService {
       game: gameId,
     });
     // check if the authenticated person already belongs to a group
-    if (
-      await this.game_PersonRepository.findOne({
-        group: Not(null),
-        person: person,
-      })
-    ) {
+    let check = await this.game_PersonRepository.findOne({
+      where: { person: person, game: gameId },
+      relations: ['group'],
+    });
+    if (check.group) {
       throw new HttpException(
         'You already belong to a group!',
         HttpStatus.BAD_REQUEST,
-- 
GitLab