diff --git a/core/Command/User/AuthTokens/Add.php b/core/Command/User/AuthTokens/Add.php index c491ced011bf6..83ea51223338b 100644 --- a/core/Command/User/AuthTokens/Add.php +++ b/core/Command/User/AuthTokens/Add.php @@ -16,6 +16,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Security\ISecureRandom; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -92,7 +93,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $password = $helper->ask($input, $output, $question); } - $loginName = $input->getOption('login-name') ?? $user->getUID(); + try { + $loginName = $input->getOption('login-name') ?? $user->getUID(); + } catch (InvalidArgumentException) { + $loginName = $user->getUID(); + } if ($password === null) { $output->writeln('No password provided. The generated app password will therefore have limited capabilities. Any operation that requires the login password will fail.');