Merge pull request #978 from nextcloud/add-feedback-for-password-change

Add feedback for password change
This commit is contained in:
Marius Blüm 2016-08-19 16:37:58 +02:00 committed by GitHub
commit 69ccb9ff7a
2 changed files with 16 additions and 3 deletions

View file

@ -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(),
],
]);
}

View file

@ -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));
}
}