From d878d3d42ff985f90df4b85fc852169fb51ef1f6 Mon Sep 17 00:00:00 2001 From: Alessandro Aglietti Date: Tue, 12 Apr 2016 11:30:30 +0200 Subject: [PATCH] PR for https://github.com/eltrino/diamantedesk-application/issues/26 it transform the JSON response from {'success' : true} to {'success' : true, 'diamanteUserId' : } --- .../FrontBundle/Api/Internal/RegistrationServiceImpl.php | 6 +++++- src/Diamante/FrontBundle/Controller/UserController.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Diamante/FrontBundle/Api/Internal/RegistrationServiceImpl.php b/src/Diamante/FrontBundle/Api/Internal/RegistrationServiceImpl.php index 523167304..d59eb3f7e 100644 --- a/src/Diamante/FrontBundle/Api/Internal/RegistrationServiceImpl.php +++ b/src/Diamante/FrontBundle/Api/Internal/RegistrationServiceImpl.php @@ -65,7 +65,7 @@ public function __construct( * Register new Diamante User and grant API access for it. * Sends confirmation email. While registration is not confirmed API access is not active * @param Command\RegisterCommand $command - * @return void + * @return int DiamanteUser id */ public function register(Command\RegisterCommand $command) { @@ -91,6 +91,10 @@ public function register(Command\RegisterCommand $command) $this->diamanteUserRepository->store($diamanteUser); $this->registrationMailer->sendConfirmationEmail($diamanteUser->getEmail(), $apiUser->getHash()); + + $diamanteUser = $this->diamanteUserRepository->findUserByEmail($command->email); + + return $diamanteUser->getId(); } /** diff --git a/src/Diamante/FrontBundle/Controller/UserController.php b/src/Diamante/FrontBundle/Controller/UserController.php index 53c18ecb4..98e4a1201 100644 --- a/src/Diamante/FrontBundle/Controller/UserController.php +++ b/src/Diamante/FrontBundle/Controller/UserController.php @@ -50,8 +50,8 @@ public function registerAction() } try { - $this->get('diamante.front.registration.service')->register($command); - $view = $this->view(['success' => true], Codes::HTTP_CREATED); + $diamanteUSerId = $this->get('diamante.front.registration.service')->register($command); + $view = $this->view(['success' => true, 'diamanteUserId' => $diamanteUSerId], Codes::HTTP_CREATED); } catch (\Exception $e) { $this->container->get('monolog.logger.diamante')->error(sprintf('Registration failed for user %s', $command->email)); $view = $this->view(['message' => $e->getMessage()], Codes::HTTP_BAD_REQUEST);