diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php deleted file mode 100644 index 7931d1d..0000000 --- a/src/Command/CreateUserCommand.php +++ /dev/null @@ -1,66 +0,0 @@ -addArgument('username', InputArgument::REQUIRED, 'Username') - ->addArgument('password', InputArgument::REQUIRED, 'Plain text password') - ->addOption('admin', 'a', InputOption::VALUE_NONE, 'Grant ROLE_ADMIN'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $io = new SymfonyStyle($input, $output); - - $username = $input->getArgument('username'); - $plainPassword = $input->getArgument('password'); - - $existing = $this->em->getRepository(User::class)->findOneBy(['username' => $username]); - - if ($existing) { - $io->error(sprintf('User "%s" already exists.', $username)); - - return Command::FAILURE; - } - - $user = new User(); - $user->setUsername($username); - $user->setPassword($this->passwordHasher->hashPassword($user, $plainPassword)); - $user->setRoles($input->getOption('admin') ? ['ROLE_ADMIN'] : []); - - $this->em->persist($user); - $this->em->flush(); - - $io->success(sprintf('User "%s" created%s.', $username, $input->getOption('admin') ? ' (admin)' : '')); - - return Command::SUCCESS; - } -}