diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-03-05 14:27:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 14:27:22 +0100 |
commit | 36c750ae1e65c4e5770457cbf4d49543a38c0a3c (patch) | |
tree | 8ca1214827e4917c6ef361e78646554c19763f7b | |
parent | c91ae1133e727156a63a8fe1bdc3ad0f05f4851a (diff) | |
parent | add43bc19c2e7681668e6bc24b06d96e0ae8bd70 (diff) | |
download | nextcloud-server-36c750ae1e65c4e5770457cbf4d49543a38c0a3c.tar.gz nextcloud-server-36c750ae1e65c4e5770457cbf4d49543a38c0a3c.zip |
Merge pull request #14451 from nextcloud/bugfix/noid/error-message-on-password-change
Check if password can be changed for the users backend in OCS api
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 3 | ||||
-rw-r--r-- | apps/provisioning_api/tests/Controller/UsersControllerTest.php | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index a034ff6d77a..c7625a26f59 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -513,6 +513,9 @@ class UsersController extends AUserData { break; case 'password': try { + if (!$targetUser->canChangePassword()) { + throw new OCSException('Setting the password is not supported by the users backend', 103); + } $targetUser->setPassword($value); } catch (HintException $e) { // password policy error throw new OCSException($e->getMessage(), 103); diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php index fcdc68d353b..c6e0082c4b0 100644 --- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php +++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php @@ -1272,6 +1272,10 @@ class UsersControllerTest extends TestCase { ->will($this->returnValue($targetUser)); $targetUser ->expects($this->once()) + ->method('canChangePassword') + ->will($this->returnValue(true)); + $targetUser + ->expects($this->once()) ->method('setPassword') ->with('NewPassword'); $targetUser |