From c0ecdf640203673801b01c9af0809c4ae87dc60a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 7 Sep 2016 09:28:42 +0200 Subject: Catch the exception of the password policy app --- core/Command/User/Add.php | 14 ++++++++++---- core/Command/User/ResetPassword.php | 9 ++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'core') 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('' . $e->getMessage() . ''); + return 1; + } + if ($user instanceof IUser) { $output->writeln('The user "' . $user->getUID() . '" was created successfully'); diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index cf8c894d7a7..62c4eceeee2 100644 --- a/core/Command/User/ResetPassword.php +++ b/core/Command/User/ResetPassword.php @@ -113,7 +113,14 @@ class ResetPassword extends Command { return 1; } - $success = $user->setPassword($password); + + try { + $success = $user->setPassword($password); + } catch (\Exception $e) { + $output->writeln('' . $e->getMessage() . ''); + return 1; + } + if ($success) { $output->writeln("Successfully reset password for " . $username . ""); } else { -- cgit v1.2.3 From 83c46f05412bbbdbf36cf967564d1cf736ff539e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 7 Sep 2016 09:32:20 +0200 Subject: Fix typo --- core/Command/User/ResetPassword.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/Command/User/ResetPassword.php b/core/Command/User/ResetPassword.php index 62c4eceeee2..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); -- cgit v1.2.3