fixup! make it possible to change email and username

This commit is contained in:
Bence Pőcze 2023-09-24 01:07:22 +02:00
parent 26d6c0922c
commit 2cd55daf3b
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D

View File

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