]> source.dussan.org Git - nextcloud-server.git/commitdiff
Catch the exception of the password policy app
authorJoas Schilling <coding@schilljs.com>
Wed, 7 Sep 2016 07:28:42 +0000 (09:28 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 7 Sep 2016 07:28:42 +0000 (09:28 +0200)
core/Command/User/Add.php
core/Command/User/ResetPassword.php

index 368f06cba8572c450acf0857a16eb8c90cfee73e..8dd25a7f29739ef76386d1bf3c2f7923f44f7b4d 100644 (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>');
index cf8c894d7a7942933dfa7572591b90bdaf558494..62c4eceeee2a9618d6b28aece854f3990df98fe1 100644 (file)
@@ -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 {