summaryrefslogtreecommitdiffstats
path: root/settings/Controller
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-08-19 13:31:43 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-08-19 13:31:43 +0200
commit429eb217809e93d3b6c3797faec385209d66f212 (patch)
treef4e2ab7084a72085fd02036024c375b77746fdbb /settings/Controller
parentdfb66e110122947e6aabb2c61941a9d2cc9a5908 (diff)
downloadnextcloud-server-429eb217809e93d3b6c3797faec385209d66f212.tar.gz
nextcloud-server-429eb217809e93d3b6c3797faec385209d66f212.zip
Show hint if password policy disallows password change
Diffstat (limited to 'settings/Controller')
-rw-r--r--settings/Controller/ChangePasswordController.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/settings/Controller/ChangePasswordController.php b/settings/Controller/ChangePasswordController.php
index 74abd8b57d3..df170b62f1a 100644
--- a/settings/Controller/ChangePasswordController.php
+++ b/settings/Controller/ChangePasswordController.php
@@ -21,6 +21,7 @@
*/
namespace OC\Settings\Controller;
+use OC\HintException;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
@@ -233,11 +234,21 @@ class ChangePasswordController extends Controller {
}
}
} else {
- if ($targetUser->setPassword($password) === false) {
+ try {
+ if ($targetUser->setPassword($password) === false) {
+ return new JSONResponse([
+ 'status' => 'error',
+ 'data' => [
+ 'message' => $this->l->t('Unable to change password'),
+ ],
+ ]);
+ }
+ // password policy app throws exception
+ } catch(HintException $e) {
return new JSONResponse([
'status' => 'error',
'data' => [
- 'message' => $this->l->t('Unable to change password'),
+ 'message' => $e->getHint(),
],
]);
}