From dfb66e110122947e6aabb2c61941a9d2cc9a5908 Mon Sep 17 00:00:00 2001 From: Jack Davis Date: Fri, 19 Aug 2016 09:45:39 +0100 Subject: [PATCH 1/2] 25532_issue_password_update_notification_updated (#25756) * Password Update Notification Added an IF ELSE statement to ensure that feedback is provided to the user on successfully updating a user password in settings. * Password Update Success Message Updated the password update success message --- settings/js/users/users.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/settings/js/users/users.js b/settings/js/users/users.js index 6be7b2d952644..78118d5c5aa5d 100644 --- a/settings/js/users/users.js +++ b/settings/js/users/users.js @@ -670,7 +670,9 @@ $(document).ready(function () { OC.generateUrl('/settings/users/changepassword'), {username: uid, password: $(this).val(), recoveryPassword: recoveryPasswordVal}, function (result) { - if (result.status != 'success') { + if (result.status === 'success') { + OC.Notification.showTemporary(t('admin', 'Password successfully changed')); + } else { OC.Notification.showTemporary(t('admin', result.data.message)); } } From 429eb217809e93d3b6c3797faec385209d66f212 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 19 Aug 2016 13:31:43 +0200 Subject: [PATCH 2/2] Show hint if password policy disallows password change --- settings/Controller/ChangePasswordController.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/settings/Controller/ChangePasswordController.php b/settings/Controller/ChangePasswordController.php index 74abd8b57d3af..df170b62f1a1b 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 @@ public function changeUserPassword($username = null, $password = null, $recovery } } } 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(), ], ]); }