Browse Source
Show hint if password policy disallows password change
pull/978/head
Morris Jobke
10 years ago
No known key found for this signature in database
GPG Key ID: 9CE5ED29E7FCD38A
1 changed files with
13 additions and
2 deletions
-
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(), |
|
|
|
], |
|
|
|
]); |
|
|
|
} |
|
|
|
|