Browse Source

Merge pull request #26394 from nextcloud/feature/noid/updatable-account-data

Allow apps to write/update account data
tags/v22.0.0beta1
Julius Härtl 3 years ago
parent
commit
bbc64cfabc
No account linked to committer's email address
2 changed files with 24 additions and 0 deletions
  1. 14
    0
      lib/private/Accounts/AccountManager.php
  2. 10
    0
      lib/public/Accounts/IAccountManager.php

+ 14
- 0
lib/private/Accounts/AccountManager.php View File

@@ -510,4 +510,18 @@ class AccountManager implements IAccountManager {
public function getAccount(IUser $user): IAccount {
return $this->parseAccountData($user, $this->getUser($user));
}

public function updateAccount(IAccount $account): void {
$data = [];

foreach ($account->getProperties() as $property) {
$data[$property->getName()] = [
'value' => $property->getValue(),
'scope' => $property->getScope(),
'verified' => $property->getVerified(),
];
}

$this->updateUser($account->getUser(), $data, true);
}
}

+ 10
- 0
lib/public/Accounts/IAccountManager.php View File

@@ -110,6 +110,16 @@ interface IAccountManager {
*/
public function getAccount(IUser $user): IAccount;

/**
* Update the account data with for the user
*
* @since 21.0.1
*
* @param IAccount $account
* @throws \InvalidArgumentException Message is the property that was invalid
*/
public function updateAccount(IAccount $account): void;

/**
* Search for users based on account data
*

Loading…
Cancel
Save