aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-03-01 10:11:37 +0100
committerBackportbot <backportbot-noreply@rullzer.com>2019-03-05 13:28:05 +0000
commit37ba2562cfd96c7430a765a2bc2be3f522cd40e9 (patch)
tree1988b46f387d9ceb8175e083f067f9c2870a36d0
parentb88eb01798a7402ba666ca0e7f08949ff3119c0f (diff)
downloadnextcloud-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.php3
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php4
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