Compare commits
8 Commits
dff84f3df0
...
52873fc759
Author | SHA1 | Date | |
---|---|---|---|
52873fc759 | |||
0882a67019 | |||
49069f4a52 | |||
4bba7599e1 | |||
7fb75c9f25 | |||
5d367d5b35 | |||
a2d6376e81 | |||
f3c3aa69eb |
@ -1,6 +1,6 @@
|
||||
# MapGuesser
|
||||
|
||||
[![Build Status](https://jenkins.e5tv.hu/job/mapguesser/job/develop/badge/icon)](https://jenkins.e5tv.hu/job/mapguesser/job/develop/)
|
||||
[![Build Status](https://ci.esoko.eu/job/mapguesser/job/develop/badge/icon)](https://ci.esoko.eu/job/mapguesser/job/develop/)
|
||||
|
||||
This is the MapGuesser Application project. This is a game about guessing where you are based on a street view panorama - inspired by existing applications.
|
||||
|
||||
@ -80,7 +80,7 @@ docker compose up -d
|
||||
**And you are done!** The application is ready to use. You can create the first administrative user with the following command after attaching to the `app` container:
|
||||
|
||||
```
|
||||
./mapg user:add EMAIL PASSWORD admin
|
||||
./mapg user:add EMAIL USERNAME PASSWORD admin
|
||||
```
|
||||
|
||||
## Development
|
||||
|
@ -89,6 +89,9 @@ var MapGuesser = {
|
||||
|
||||
formError.style.display = 'block';
|
||||
formError.innerHTML = this.response.error.errorText;
|
||||
if (typeof grecaptcha !== 'undefined') {
|
||||
grecaptcha.reset();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ 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');;
|
||||
}
|
||||
@ -22,6 +23,7 @@ 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());
|
||||
|
@ -364,11 +364,24 @@ 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).']]);
|
||||
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));
|
||||
}
|
||||
|
||||
$newUser->setUsername(strlen(\Container::$request->post('username')) > 0 ? \Container::$request->post('username') : (new UsernameGenerator())->generate());
|
||||
$newUser->setUsername($username);
|
||||
$newUser->setCreatedDate(new DateTime());
|
||||
|
||||
\Container::$persistentDataManager->saveToDb($newUser);
|
||||
|
@ -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).']]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user