From edf91ae01db7c82490bf1c0f2678177bced0bf41 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 4 Mar 2026 09:06:33 +0100 Subject: [PATCH] Fix user creation bug --- src/Controller/UserController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 819c664..8631216 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -872,11 +872,12 @@ class UserController extends AbstractController $email = $user->getEmail(); $existingUser = $this->userRepository->findOneBy(['email' => $email]); - if($this->userService->checkUserOrganizationLinkExists($existingUser, $org)){ - return $this->json(['error' => "L'utilisateur existe déjà dans votre organisation"], 400); - } + // CASE A: User exists -> Add to org if ($existingUser) { + if($this->userService->checkUserOrganizationLinkExists($existingUser, $org)){ + return $this->json(['error' => "L'utilisateur existe déjà dans votre organisation"], 400); + } // Check if already in org to avoid logic errors or duplicate logs $this->userService->addExistingUserToOrganization($existingUser, $org, $selectedApps);