mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 08:44:07 -04:00
Merge pull request #32276 from nextcloud/fix/ldap_error_handling
Do not dispatch postSetPassword when setPassword fails
This commit is contained in:
commit
0284c0f717
3 changed files with 20 additions and 7 deletions
|
|
@ -109,7 +109,10 @@ class ChangePasswordController extends Controller {
|
|||
try {
|
||||
if ($newpassword === null || $user->setPassword($newpassword) === false) {
|
||||
return new JSONResponse([
|
||||
'status' => 'error'
|
||||
'status' => 'error',
|
||||
'data' => [
|
||||
'message' => $this->l->t('Unable to change personal password'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
// password policy app throws exception
|
||||
|
|
|
|||
|
|
@ -320,13 +320,17 @@ class User implements IUser {
|
|||
}
|
||||
if ($this->backend->implementsActions(Backend::SET_PASSWORD)) {
|
||||
$result = $this->backend->setPassword($this->uid, $password);
|
||||
$this->legacyDispatcher->dispatch(IUser::class . '::postSetPassword', new GenericEvent($this, [
|
||||
'password' => $password,
|
||||
'recoveryPassword' => $recoveryPassword,
|
||||
]));
|
||||
if ($this->emitter) {
|
||||
$this->emitter->emit('\OC\User', 'postSetPassword', [$this, $password, $recoveryPassword]);
|
||||
|
||||
if ($result !== false) {
|
||||
$this->legacyDispatcher->dispatch(IUser::class . '::postSetPassword', new GenericEvent($this, [
|
||||
'password' => $password,
|
||||
'recoveryPassword' => $recoveryPassword,
|
||||
]));
|
||||
if ($this->emitter) {
|
||||
$this->emitter->emit('\OC\User', 'postSetPassword', [$this, $password, $recoveryPassword]);
|
||||
}
|
||||
}
|
||||
|
||||
return !($result === false);
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -138,6 +138,9 @@ class ChangePasswordControllerTest extends \Test\TestCase {
|
|||
|
||||
$expects = [
|
||||
'status' => 'error',
|
||||
'data' => [
|
||||
'message' => 'Unable to change personal password',
|
||||
],
|
||||
];
|
||||
|
||||
$res = $this->controller->changePersonalPassword('old');
|
||||
|
|
@ -163,6 +166,9 @@ class ChangePasswordControllerTest extends \Test\TestCase {
|
|||
|
||||
$expects = new JSONResponse([
|
||||
'status' => 'error',
|
||||
'data' => [
|
||||
'message' => 'Unable to change personal password',
|
||||
],
|
||||
]);
|
||||
|
||||
$actual = $this->controller->changePersonalPassword('old', 'new');
|
||||
|
|
|
|||
Loading…
Reference in a new issue