Skip to content

Commit 69ccb9f

Browse files
authored
Merge pull request #978 from nextcloud/add-feedback-for-password-change
Add feedback for password change
2 parents a9697ea + 429eb21 commit 69ccb9f

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

settings/Controller/ChangePasswordController.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
namespace OC\Settings\Controller;
2323

24+
use OC\HintException;
2425
use OCP\App\IAppManager;
2526
use OCP\AppFramework\Controller;
2627
use OCP\AppFramework\Http\JSONResponse;
@@ -233,11 +234,21 @@ public function changeUserPassword($username = null, $password = null, $recovery
233234
}
234235
}
235236
} else {
236-
if ($targetUser->setPassword($password) === false) {
237+
try {
238+
if ($targetUser->setPassword($password) === false) {
239+
return new JSONResponse([
240+
'status' => 'error',
241+
'data' => [
242+
'message' => $this->l->t('Unable to change password'),
243+
],
244+
]);
245+
}
246+
// password policy app throws exception
247+
} catch(HintException $e) {
237248
return new JSONResponse([
238249
'status' => 'error',
239250
'data' => [
240-
'message' => $this->l->t('Unable to change password'),
251+
'message' => $e->getHint(),
241252
],
242253
]);
243254
}

settings/js/users/users.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,9 @@ $(document).ready(function () {
670670
OC.generateUrl('/settings/users/changepassword'),
671671
{username: uid, password: $(this).val(), recoveryPassword: recoveryPasswordVal},
672672
function (result) {
673-
if (result.status != 'success') {
673+
if (result.status === 'success') {
674+
OC.Notification.showTemporary(t('admin', 'Password successfully changed'));
675+
} else {
674676
OC.Notification.showTemporary(t('admin', result.data.message));
675677
}
676678
}

0 commit comments

Comments
 (0)