diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 1f0d5cf..4b825d0 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -167,8 +167,8 @@ class UserController implements IAuthenticationRequired $newUsername = \Container::$request->post('username'); if (strlen($newUsername) > 0 && $newUsername !== $user->getUsername()) { - if (filter_var($newUsername, FILTER_VALIDATE_EMAIL)) { - return new JsonContent(['error' => ['errorText' => 'Please select a username that is not a valid email address.']]); + if (preg_match('/^[a-zA-Z0-9_\-\.]+$/', $newUsername) !== 1) { + return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]); } if ($this->userRepository->getByUsername($newUsername) !== null) {