diff --git a/src/controllers/User/Register.php b/src/controllers/User/Register.php index 84926ead..b30fa2cd 100644 --- a/src/controllers/User/Register.php +++ b/src/controllers/User/Register.php @@ -136,6 +136,13 @@ protected function tryRegister(Router &$router, UserRegisterModel &$model) { return; } } catch (UserNotFoundException $e) {} + + try { + if (User::findIdByUsername($username)) { + $model->error = "USERNAME_TAKEN"; + return; + } + } catch (UserNotFoundException $e) {} try { diff --git a/src/templates/User/Register.phtml b/src/templates/User/Register.phtml index 3183d06b..73ec361c 100644 --- a/src/templates/User/Register.phtml +++ b/src/templates/User/Register.phtml @@ -70,6 +70,10 @@ switch ($this->getContext()->error) { $af = "email"; $message = "The email address is already in use, use another."; break; + case "USERNAME_TAKEN": + $af = "username"; + $message = "That username is taken, try another."; + break; case "INTERNAL_ERROR": $af = null; $message = "An internal error occurred while processing your request. "