bugfix/username-validation-fixes #72
@ -290,7 +290,11 @@ class UserController implements IAuthenticationRequired
|
||||
}
|
||||
|
||||
$newUsername = \Container::$request->post('username');
|
||||
if (strlen($newUsername) > 0 && $newUsername !== $user->getUsername()) {
|
||||
if ($newUsername !== $user->getUsername()) {
|
||||
if (strlen($newUsername) == 0) {
|
||||
return new JsonContent(['error' => ['errorText' => 'Username cannot be empty.']]);
|
||||
}
|
||||
|
||||
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