diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-03-01 10:11:37 +0100 |
---|---|---|
committer | Backportbot <backportbot-noreply@rullzer.com> | 2019-03-05 13:28:05 +0000 |
commit | 37ba2562cfd96c7430a765a2bc2be3f522cd40e9 (patch) | |
tree | 1988b46f387d9ceb8175e083f067f9c2870a36d0 | |
parent | b88eb01798a7402ba666ca0e7f08949ff3119c0f (diff) | |
download | nextcloud-server-37ba2562cfd96c7430a765a2bc2be3f522cd40e9.tar.gz nextcloud-server-37ba2562cfd96c7430a765a2bc2be3f522cd40e9.zip |
Check if password can be changed for the users backend in OCS api
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-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 6f98129fbd9..c8882f7b008 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 0d6d811acbc..7b235a1d5ab 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 |