bugfix/username-validation-fixes #72

Merged
bence merged 3 commits from bugfix/username-validation-fixes into develop 2023-09-25 21:21:48 +02:00
Showing only changes of commit a2d6376e81 - Show all commits

View File

@ -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).']]);
}