From da4ad1c0a2ecedc7b5e44b458fe7e31ccc2cdb0c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 20 Mar 2015 04:24:50 +0100 Subject: [PATCH] show a better error message when trying to create a user that already exists --- settings/controller/userscontroller.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php index 11afe51401..a6faa3c4a1 100644 --- a/settings/controller/userscontroller.php +++ b/settings/controller/userscontroller.php @@ -286,6 +286,15 @@ class UsersController extends Controller { } } + if ($this->userManager->userExists($username)) { + return new DataResponse( + array( + 'message' => (string)$this->l10n->t('A user with that name already exists.') + ), + Http::STATUS_CONFLICT + ); + } + try { $user = $this->userManager->createUser($username, $password); } catch (\Exception $exception) {