Compare commits

..

2 Commits

Author SHA1 Message Date
dff84f3df0
fix cli user creation usage
All checks were successful
mapguesser/pipeline/pr-develop This commit looks good
2023-09-25 21:24:10 +02:00
d89e846742
fix build badge link 2023-09-25 21:23:36 +02:00
4 changed files with 4 additions and 26 deletions

View File

@ -89,9 +89,6 @@ var MapGuesser = {
formError.style.display = 'block';
formError.innerHTML = this.response.error.errorText;
if (typeof grecaptcha !== 'undefined') {
grecaptcha.reset();
}
return;
}

View File

@ -14,7 +14,6 @@ class AddUserCommand extends Command
$this->setName('user:add')
->setDescription('Adding of user.')
->addArgument('email', InputArgument::REQUIRED, 'Email of user')
->addArgument('username', InputArgument::REQUIRED, 'Username of user')
->addArgument('password', InputArgument::REQUIRED, 'Password of user')
->addArgument('type', InputArgument::OPTIONAL, 'Type of user');;
}
@ -23,7 +22,6 @@ class AddUserCommand extends Command
{
$user = new User();
$user->setEmail($input->getArgument('email'));
$user->setUsername($input->getArgument('username'));
$user->setPlainPassword($input->getArgument('password'));
$user->setActive(true);
$user->setCreatedDate(new DateTime());

View File

@ -364,24 +364,11 @@ class LoginController
$newUser->setPlainPassword(\Container::$request->post('password'));
}
if (strlen(\Container::$request->post('username')) > 0) {
$username = \Container::$request->post('username');
if (preg_match('/^[a-zA-Z0-9_\-\.]+$/', $username) !== 1) {
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
}
if ($this->userRepository->getByUsername($username) !== null) {
return new JsonContent(['error' => ['errorText' => 'The given username is already taken.']]);
}
} else {
$usernameGenerator = new UsernameGenerator();
do {
$username = $usernameGenerator->generate();
} while ($this->userRepository->getByUsername($username));
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($username);
$newUser->setUsername(strlen(\Container::$request->post('username')) > 0 ? \Container::$request->post('username') : (new UsernameGenerator())->generate());
$newUser->setCreatedDate(new DateTime());
\Container::$persistentDataManager->saveToDb($newUser);

View File

@ -290,11 +290,7 @@ class UserController implements IAuthenticationRequired
}
$newUsername = \Container::$request->post('username');
if ($newUsername !== $user->getUsername()) {
if (strlen($newUsername) == 0) {
return new JsonContent(['error' => ['errorText' => 'Username cannot be empty.']]);
}
if (strlen($newUsername) > 0 && $newUsername !== $user->getUsername()) {
if (preg_match('/^[a-zA-Z0-9_\-\.]+$/', $newUsername) !== 1) {
return new JsonContent(['error' => ['errorText' => 'Username can contain only english letters, digits, - (hyphen), . (dot), _ (underscore).']]);
}