Merge pull request #1297 from nextcloud/catch-exceptions-with-invalid-passwords

Catch the exception of the password policy app
This commit is contained in:
Roeland Jago Douma 2016-09-08 19:54:27 +02:00 committed by GitHub
commit e18fecae47
2 changed files with 19 additions and 6 deletions

View file

@ -115,10 +115,16 @@ class Add extends Command {
return 1;
}
$user = $this->userManager->createUser(
$input->getArgument('uid'),
$password
);
try {
$user = $this->userManager->createUser(
$input->getArgument('uid'),
$password
);
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
}
if ($user instanceof IUser) {
$output->writeln('<info>The user "' . $user->getUID() . '" was created successfully</info>');

View file

@ -100,7 +100,7 @@ class ResetPassword extends Command {
$question->setHidden(true);
$password = $helper->ask($input, $output, $question);
$question = new Question('Conform the new password: ');
$question = new Question('Confirm the new password: ');
$question->setHidden(true);
$confirm = $helper->ask($input, $output, $question);
@ -113,7 +113,14 @@ class ResetPassword extends Command {
return 1;
}
$success = $user->setPassword($password);
try {
$success = $user->setPassword($password);
} catch (\Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return 1;
}
if ($success) {
$output->writeln("<info>Successfully reset password for " . $username . "</info>");
} else {