Compare commits
No commits in common. "4bba7599e1a897962fe4e22620f794828561ba65" and "467399c81b2a531b4126fd935d7c1748500c5400" have entirely different histories.
4bba7599e1
...
467399c81b
@ -89,9 +89,6 @@ var MapGuesser = {
|
||||
|
||||
formError.style.display = 'block';
|
||||
formError.innerHTML = this.response.error.errorText;
|
||||
if (typeof grecaptcha !== 'undefined') {
|
||||
grecaptcha.reset();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -364,24 +364,11 @@ class LoginController
|
||||
$newUser->setPlainPassword(\Container::$request->post('password'));
|
||||
}
|
||||
|
||||
if (strlen(\Container::$request->post('username')) > 0) {
|
||||
$username = \Container::$request->post('username');
|
||||
|
||||
if (preg_match('/^[a-zA-Z0-9_\-\.]+$/', $username) !== 1) {
|
||||
if (strlen(\Container::$request->post('username')) > 0 && preg_match('/^[a-zA-Z0-9_\-\.]+$/', \Container::$request->post('username')) !== 1) {
|
||||
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
|
||||
}
|
||||
|
||||
if ($this->userRepository->getByUsername($username) !== null) {
|
||||
return new JsonContent(['error' => ['errorText' => 'The given username is already taken.']]);
|
||||
}
|
||||
} else {
|
||||
$usernameGenerator = new UsernameGenerator();
|
||||
do {
|
||||
$username = $usernameGenerator->generate();
|
||||
} while ($this->userRepository->getByUsername($username));
|
||||
}
|
||||
|
||||
$newUser->setUsername($username);
|
||||
$newUser->setUsername(strlen(\Container::$request->post('username')) > 0 ? \Container::$request->post('username') : (new UsernameGenerator())->generate());
|
||||
$newUser->setCreatedDate(new DateTime());
|
||||
|
||||
\Container::$persistentDataManager->saveToDb($newUser);
|
||||
|
@ -290,11 +290,7 @@ class UserController implements IAuthenticationRequired
|
||||
}
|
||||
|
||||
$newUsername = \Container::$request->post('username');
|
||||
if ($newUsername !== $user->getUsername()) {
|
||||
if (strlen($newUsername) == 0) {
|
||||
return new JsonContent(['error' => ['errorText' => 'Username cannot be empty.']]);
|
||||
}
|
||||
|
||||
if (strlen($newUsername) > 0 && $newUsername !== $user->getUsername()) {
|
||||
if (preg_match('/^[a-zA-Z0-9_\-\.]+$/', $newUsername) !== 1) {
|
||||
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user