fixup! merge signup and google signup handling with username support

This commit is contained in:
Bence Pőcze 2023-09-24 01:13:29 +02:00
parent e2dd78fca3
commit bec8b79680
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D

View File

@ -336,10 +336,6 @@ class LoginController
return new JsonContent(['error' => ['errorText' => 'The given email address is not valid.']]);
}
if (strlen(\Container::$request->post('username')) > 0 && preg_match('/^[a-zA-Z0-9_\-\.]+$/', \Container::$request->post('username')) !== 1) {
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
}
if (\Container::$request->session()->has('tmp_user_data')) {
$tmpUserData = \Container::$request->session()->get('tmp_user_data');
@ -368,6 +364,10 @@ class LoginController
$newUser->setPlainPassword(\Container::$request->post('password'));
}
if (strlen(\Container::$request->post('username')) > 0 && preg_match('/^[a-zA-Z0-9_\-\.]+$/', \Container::$request->post('username')) !== 1) {
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
}
$newUser->setUsername(strlen(\Container::$request->post('username')) > 0 ? \Container::$request->post('username') : Factory::create()->userName);
$newUser->setCreatedDate(new DateTime());