From add43bc19c2e7681668e6bc24b06d96e0ae8bd70 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 1 Mar 2019 10:11:37 +0100 Subject: Check if password can be changed for the users backend in OCS api MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/provisioning_api/lib/Controller/UsersController.php | 3 +++ apps/provisioning_api/tests/Controller/UsersControllerTest.php | 4 ++++ 2 files changed, 7 insertions(+) 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 @@ -1270,6 +1270,10 @@ class UsersControllerTest extends TestCase { ->method('get') ->with('UserToEdit') ->will($this->returnValue($targetUser)); + $targetUser + ->expects($this->once()) + ->method('canChangePassword') + ->will($this->returnValue(true)); $targetUser ->expects($this->once()) ->method('setPassword') -- cgit v1.2.3