diff --git a/src/Command/User/SetPasswordCommand.php b/src/Command/User/SetPasswordCommand.php index 66e6e97e..78724ecf 100644 --- a/src/Command/User/SetPasswordCommand.php +++ b/src/Command/User/SetPasswordCommand.php @@ -56,7 +56,7 @@ class SetPasswordCommand extends Command $this ->setDescription('Sets the password of a user') ->setHelp('This password allows you to set the password of a user, without knowing the old password.') - ->addArgument('user', InputArgument::REQUIRED, 'The name of the user') + ->addArgument('user', InputArgument::REQUIRED, 'The username or email of the user') ; } @@ -65,17 +65,14 @@ class SetPasswordCommand extends Command $io = new SymfonyStyle($input, $output); $user_name = $input->getArgument('user'); - /** @var User[] $users */ - $users = $this->entityManager->getRepository(User::class)->findBy(['name' => $user_name]); + $user = $this->entityManager->getRepository(User::class)->findByEmailOrName($user_name); - if (empty($users)) { + if (!$user) { $io->error(sprintf('No user with the given username %s found in the database!', $user_name)); return 1; } - $user = $users[0]; - $io->note('User found!'); if ($user->isSamlUser()) { diff --git a/src/Command/User/UsersPermissionsCommand.php b/src/Command/User/UsersPermissionsCommand.php index 3cccd8fd..3d57a4dc 100644 --- a/src/Command/User/UsersPermissionsCommand.php +++ b/src/Command/User/UsersPermissionsCommand.php @@ -57,7 +57,7 @@ class UsersPermissionsCommand extends Command protected function configure(): void { $this - ->addArgument('user', InputArgument::REQUIRED, 'The username of the user to view') + ->addArgument('user', InputArgument::REQUIRED, 'The username or email of the user to view') ->addOption('noInherit', null, InputOption::VALUE_NONE, 'Do not inherit permissions from groups') ->addOption('edit', '', InputOption::VALUE_NONE, 'Edit the permissions of the user') ;