Skip to content

Commit 0532077

Browse files
authored
Merge pull request #14543 from nextcloud/backport/14451/stable14
[stable14] Check if password can be changed for the users backend in OCS api
2 parents 45af4e6 + 05f3aba commit 0532077

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

apps/provisioning_api/lib/Controller/UsersController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ public function editUser(string $userId, string $key, string $value): DataRespon
513513
break;
514514
case 'password':
515515
try {
516+
if (!$targetUser->canChangePassword()) {
517+
throw new OCSException('Setting the password is not supported by the users backend', 103);
518+
}
516519
$targetUser->setPassword($value);
517520
} catch (HintException $e) { // password policy error
518521
throw new OCSException($e->getMessage(), 103);

apps/provisioning_api/tests/Controller/UsersControllerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,10 @@ public function testEditUserRegularUserSelfEditChangePassword() {
12311231
->method('get')
12321232
->with('UserToEdit')
12331233
->will($this->returnValue($targetUser));
1234+
$targetUser
1235+
->expects($this->once())
1236+
->method('canChangePassword')
1237+
->will($this->returnValue(true));
12341238
$targetUser
12351239
->expects($this->once())
12361240
->method('setPassword')

0 commit comments

Comments
 (0)