diff --git a/src/core/controllers/InstallerController.php b/src/core/controllers/InstallerController.php index a683446ddde25f2942daa8a5de94f225577f2056..1f02d050f0c8432c12f9fd7ca1a75ec64c8f2873 100644 --- a/src/core/controllers/InstallerController.php +++ b/src/core/controllers/InstallerController.php @@ -538,6 +538,11 @@ class InstallerController DatabasePDO::reset(); new DatabasePDO(['customId' => $body['customId']]); + $userAlreadyExists = UserModel::getByLogin(['login' => strtolower($body['login']), 'select' => 1]); + if (!empty($userAlreadyExists)) { + return $response->withStatus(400)->withJson(['errors' => 'User already exists', 'lang' => 'alreadyExist']); + } + UserModel::create([ 'user' => [ 'userId' => $body['login'], diff --git a/test/unitTests/app/user/UserControllerTest.php b/test/unitTests/app/user/UserControllerTest.php index 469026ad2859c67db46ffb36ba64fdd87f0d2fdf..9a71fb2f0f85e5454bbeb5c6d853da7298564d5e 100755 --- a/test/unitTests/app/user/UserControllerTest.php +++ b/test/unitTests/app/user/UserControllerTest.php @@ -290,7 +290,7 @@ class UserControllerTest extends TestCase $response = $userController->update($fullRequest, new \Slim\Http\Response(), ['id' => self::$id]); $this->assertSame(400, $response->getStatusCode()); $responseBody = json_decode((string)$response->getBody(), true); - $this->assertSame('Bad Request', $responseBody['errors']); + $this->assertSame('Body phone is not correct', $responseBody['errors']); } public function testAddGroup()