✨ feat(AccountCommand): Ajoute la création d'un utilisateur administrateur via la commande.
🐛 fix(ResetPasswordEvent): Autorise une valeur nulle pour l'email dans ResetPasswordEvent.
This commit is contained in:
@@ -33,7 +33,11 @@ class AccountCommand extends Command
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->title("Création d'un utilisateur administrateur");
|
||||
|
||||
$existingUser = $this->entityManager->getRepository(Account::class)->findOneBy(['email' => 'jovann@siteconseil.fr']);
|
||||
$email = $io->askQuestion(new Question("Email ?"));
|
||||
|
||||
$username = $io->askQuestion(new Question("Username ?"));
|
||||
|
||||
$existingUser = $this->entityManager->getRepository(Account::class)->findOneBy(['email' => $email]);
|
||||
if (!$existingUser instanceof Account) {
|
||||
$password = TempPasswordGenerator::generate();
|
||||
$newUser = new Account();
|
||||
@@ -41,13 +45,11 @@ class AccountCommand extends Command
|
||||
$newUser->setUuid(Uuid::v4());
|
||||
$newUser->setIsActif(true);
|
||||
$newUser->setIsFirstLogin(true);
|
||||
|
||||
$email = $io->askQuestion(new Question("Email ?"));
|
||||
$newUser->setEmail($email);
|
||||
|
||||
$username = $io->askQuestion(new Question("Username ?"));
|
||||
$newUser->setUsername($username);
|
||||
|
||||
|
||||
|
||||
$hashedPassword = $this->userPasswordHasher->hashPassword($newUser, $password);
|
||||
$newUser->setPassword($hashedPassword);
|
||||
|
||||
@@ -58,7 +60,7 @@ class AccountCommand extends Command
|
||||
|
||||
$io->success("Utilisateur administrateur créé avec succès.");
|
||||
} else {
|
||||
$io->warning("Un utilisateur avec l'email 'jovann@siteconseil.fr' existe déjà.");
|
||||
$io->warning("Un utilisateur avec l'email existe déjà.");
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Service\ResetPassword\Event;
|
||||
|
||||
class ResetPasswordEvent
|
||||
{
|
||||
public function __construct(private string $email)
|
||||
public function __construct(private ?string $email=null)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user