Skip to content

Commit 36c750a

Browse files
authored
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
2 parents c91ae11 + add43bc commit 36c750a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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
@@ -1270,6 +1270,10 @@ public function testEditUserRegularUserSelfEditChangePassword() {
12701270
->method('get')
12711271
->with('UserToEdit')
12721272
->will($this->returnValue($targetUser));
1273+
$targetUser
1274+
->expects($this->once())
1275+
->method('canChangePassword')
1276+
->will($this->returnValue(true));
12731277
$targetUser
12741278
->expects($this->once())
12751279
->method('setPassword')

0 commit comments

Comments
 (0)