|
@@ -35,11 +35,22 @@ class UserCreateCommand extends Command
|
|
|
{
|
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
|
|
- $name = $io->ask("Nom de l'utilisateur");
|
|
|
$email = $io->ask("Email de l'utilisateur");
|
|
|
+
|
|
|
+ $user = $this->userRepository->findOneBy(['email' => $email]);
|
|
|
+
|
|
|
+ if ($user) {
|
|
|
+ $modif = $io->confirm(sprintf("Utilisateur existant : %s\nVoulez vous le modifier", $user->getPseudo()), false);
|
|
|
+ if (!$modif) {
|
|
|
+ $io->info("Pas de modification");
|
|
|
+ return Command::SUCCESS;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $name = $io->ask("Nom de l'utilisateur");
|
|
|
$plainPassword = $io->askHidden("Mot de passe");
|
|
|
-
|
|
|
- $user = new User();
|
|
|
+
|
|
|
+ $user = $user ?? new User();
|
|
|
$user->setName($name);
|
|
|
$user->setEmail($email);
|
|
|
$user->setPassword($this->passwordHasher->hashPassword($user, $plainPassword));
|
|
@@ -47,7 +58,7 @@ class UserCreateCommand extends Command
|
|
|
$errors = $this->validator->validate($user);
|
|
|
if (count($errors) > 0) {
|
|
|
$errorsString = (string) $errors;
|
|
|
- $io->error($$errorsString);
|
|
|
+ $io->error($errorsString);
|
|
|
return Command::INVALID;
|
|
|
}
|
|
|
|