check if username is empty in usercontroller
This commit is contained in:
parent
467399c81b
commit
a2d6376e81
@ -290,7 +290,11 @@ class UserController implements IAuthenticationRequired
|
|||||||
}
|
}
|
||||||
|
|
||||||
$newUsername = \Container::$request->post('username');
|
$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) {
|
if (preg_match('/^[a-zA-Z0-9_\-\.]+$/', $newUsername) !== 1) {
|
||||||
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
|
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user