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
This commit is contained in:
Morris Jobke 2019-03-05 14:27:22 +01:00 committed by GitHub
commit 36c750ae1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View file

@ -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);

View file

@ -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')