diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-06-11 13:34:53 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2021-06-30 00:41:10 +0200 |
commit | 13818005a3a5b3c6f296810eca64053722a35899 (patch) | |
tree | 72373c08fc540b79d470675bb839812f95d04a91 /lib/private/Accounts | |
parent | 4aece4cae92cd81f6385016f58e5dd91e38b2658 (diff) | |
download | nextcloud-server-13818005a3a5b3c6f296810eca64053722a35899.tar.gz nextcloud-server-13818005a3a5b3c6f296810eca64053722a35899.zip |
prov api reports additional emails on getUser
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'lib/private/Accounts')
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 4d75c94346b..ddc4e7c2fb0 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -39,6 +39,7 @@ use libphonenumber\PhoneNumberUtil; use OCA\Settings\BackgroundJobs\VerifyUserData; use OCP\Accounts\IAccount; use OCP\Accounts\IAccountManager; +use OCP\Accounts\IAccountPropertyCollection; use OCP\BackgroundJob\IJobList; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; @@ -400,10 +401,13 @@ class AccountManager implements IAccountManager { */ protected function addMissingDefaultValues(array $userData) { foreach ($userData as $key => $value) { - if (!isset($userData[$key]['verified'])) { + if (!isset($userData[$key]['verified']) && !$this->isCollection($key)) { $userData[$key]['verified'] = self::NOT_VERIFIED; } } + if (!isset($userData[IAccountManager::COLLECTION_EMAIL])) { + $userData[IAccountManager::COLLECTION_EMAIL] = []; + } return $userData; } @@ -582,13 +586,33 @@ class AccountManager implements IAccountManager { 'scope' => self::SCOPE_LOCAL, 'verified' => self::NOT_VERIFIED, ], + self::COLLECTION_EMAIL => [], ]; } + private function arrayDataToCollection(string $collectionName, array $data): IAccountPropertyCollection { + $collection = new AccountPropertyCollection($collectionName); + foreach ($data as $propertyData) { + $p = new AccountProperty( + $collectionName, + $propertyData['value'] ?? '', + $propertyData['scope'] ?? self::SCOPE_LOCAL, + $propertyData['verified'] ?? self::NOT_VERIFIED, + '' + ); + $collection->addProperty($p); + } + return $collection; + } + private function parseAccountData(IUser $user, $data): Account { $account = new Account($user); foreach ($data as $property => $accountData) { - $account->setProperty($property, $accountData['value'] ?? '', $accountData['scope'] ?? self::SCOPE_LOCAL, $accountData['verified'] ?? self::NOT_VERIFIED); + if ($this->isCollection($property)) { + $account->setPropertyCollection($this->arrayDataToCollection($property, $accountData)); + } else { + $account->setProperty($property, $accountData['value'] ?? '', $accountData['scope'] ?? self::SCOPE_LOCAL, $accountData['verified'] ?? self::NOT_VERIFIED); + } } return $account; } |