diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2016-09-08 19:54:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-08 19:54:27 +0200 |
commit | e18fecae472ef9a9da0be724849285891d855b67 (patch) | |
tree | f9dd7b1d7c4c5ee3e64a0cff37374842354158a0 | |
parent | d8c4f18c0ccbf3682d021cff4367804c5580c8af (diff) | |
parent | 83c46f05412bbbdbf36cf967564d1cf736ff539e (diff) | |
download | nextcloud-server-e18fecae472ef9a9da0be724849285891d855b67.tar.gz nextcloud-server-e18fecae472ef9a9da0be724849285891d855b67.zip |
Merge pull request #1297 from nextcloud/catch-exceptions-with-invalid-passwords
Catch the exception of the password policy app
-rw-r--r-- | core/Command/User/Add.php | 14 | ||||
-rw-r--r-- | core/Command/User/ResetPassword.php | 11 |
2 files changed, 19 insertions, 6 deletions
diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php index 368f06cba85..8dd25a7f297 100644 --- a/core/Command/User/Add.php +++ b/core/Command/User/Add.php @@ -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>'); diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index cf8c894d7a7..3388ef6a1bd 100644 --- a/core/Command/User/ResetPassword.php +++ b/core/Command/User/ResetPassword.php @@ -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 { |