From f74e227a12f1cca0e544e023cfaeb38042a91071 Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Sat, 12 Oct 2024 23:29:51 +0200 Subject: [PATCH] Allow setting password explicitly in `console domjudge:reset-user-password This can be useful for example to reset the admin password to what's in `etc/initial_admin_password.secret`. --- webapp/src/Command/ResetUserPasswordCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webapp/src/Command/ResetUserPasswordCommand.php b/webapp/src/Command/ResetUserPasswordCommand.php index a8080aee9e..b0cdfe38a2 100644 --- a/webapp/src/Command/ResetUserPasswordCommand.php +++ b/webapp/src/Command/ResetUserPasswordCommand.php @@ -33,6 +33,11 @@ protected function configure(): void 'username', InputArgument::REQUIRED, 'The username of the user to reset the password of' + ) + ->addArgument( + 'password', + InputArgument::OPTIONAL, + 'The new password; if not provided a random password is generated' ); } @@ -50,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return Command::FAILURE; } - $password = Utils::generatePassword(); + $password = $input->getArgument('password') ?? Utils::generatePassword(); $user->setPassword( $this->passwordHasher->hashPassword($user, $password)