Skip to content

Commit

Permalink
Merge pull request #26398 from nextcloud/backport/26394/stable21
Browse files Browse the repository at this point in the history
[stable21] Allow apps to write/update account data
  • Loading branch information
nickvergessen authored Apr 1, 2021
2 parents 052c9ab + 0c34886 commit e0dcf64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/private/Accounts/AccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,4 +510,18 @@ private function parseAccountData(IUser $user, $data): Account {
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 changes: 10 additions & 0 deletions lib/public/Accounts/IAccountManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit e0dcf64

Please sign in to comment.