Skip to content

Commit

Permalink
Allow setting password explicitly in `console domjudge:reset-user-pas…
Browse files Browse the repository at this point in the history
…sword

This can be useful for example to reset the admin password
to what's in `etc/initial_admin_password.secret`.
  • Loading branch information
eldering committed Oct 13, 2024
1 parent 8595592 commit f74e227
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion webapp/src/Command/ResetUserPasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}

Expand All @@ -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)
Expand Down

0 comments on commit f74e227

Please sign in to comment.