diff options
Diffstat (limited to 'apps/provisioning_api/lib/Controller/AUserData.php')
-rw-r--r-- | apps/provisioning_api/lib/Controller/AUserData.php | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index c26c4f9e2d0..6f682b41f28 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -31,12 +31,13 @@ declare(strict_types=1); namespace OCA\Provisioning_API\Controller; -use OC\Accounts\AccountManager; use OC\Group\Manager; use OC\User\Backend; use OC\User\NoUserException; use OC_Helper; use OCP\Accounts\IAccountManager; +use OCP\Accounts\PropertyDoesNotExistException; +use OCP\AppFramework\Http; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; @@ -61,7 +62,7 @@ abstract class AUserData extends OCSController { protected $groupManager; /** @var IUserSession */ protected $userSession; - /** @var AccountManager */ + /** @var IAccountManager */ protected $accountManager; /** @var IFactory */ protected $l10nFactory; @@ -72,7 +73,7 @@ abstract class AUserData extends OCSController { IConfig $config, IGroupManager $groupManager, IUserSession $userSession, - AccountManager $accountManager, + IAccountManager $accountManager, IFactory $l10nFactory) { parent::__construct($appName, $request); @@ -140,30 +141,35 @@ abstract class AUserData extends OCSController { $data['subadmin'] = $this->getUserSubAdminGroupsData($targetUserObject->getUID()); $data['quota'] = $this->fillStorageInfo($targetUserObject->getUID()); - if ($includeScopes) { - $data[IAccountManager::PROPERTY_AVATAR . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(); - } - - $data[IAccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress(); - if ($includeScopes) { - $data[IAccountManager::PROPERTY_EMAIL . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(); - } - $data[IAccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName(); - if ($includeScopes) { - $data[IAccountManager::PROPERTY_DISPLAYNAME . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getScope(); - } + try { + if ($includeScopes) { + $data[IAccountManager::PROPERTY_AVATAR . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(); + } - foreach ([ - IAccountManager::PROPERTY_PHONE, - IAccountManager::PROPERTY_ADDRESS, - IAccountManager::PROPERTY_WEBSITE, - IAccountManager::PROPERTY_TWITTER, - ] as $propertyName) { - $property = $userAccount->getProperty($propertyName); - $data[$propertyName] = $property->getValue(); + $data[IAccountManager::PROPERTY_EMAIL] = $targetUserObject->getEMailAddress(); + if ($includeScopes) { + $data[IAccountManager::PROPERTY_EMAIL . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_EMAIL)->getScope(); + } + $data[IAccountManager::PROPERTY_DISPLAYNAME] = $targetUserObject->getDisplayName(); if ($includeScopes) { - $data[$propertyName . self::SCOPE_SUFFIX] = $property->getScope(); + $data[IAccountManager::PROPERTY_DISPLAYNAME . self::SCOPE_SUFFIX] = $userAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME)->getScope(); + } + + foreach ([ + IAccountManager::PROPERTY_PHONE, + IAccountManager::PROPERTY_ADDRESS, + IAccountManager::PROPERTY_WEBSITE, + IAccountManager::PROPERTY_TWITTER, + ] as $propertyName) { + $property = $userAccount->getProperty($propertyName); + $data[$propertyName] = $property->getValue(); + if ($includeScopes) { + $data[$propertyName . self::SCOPE_SUFFIX] = $property->getScope(); + } } + } catch (PropertyDoesNotExistException $e) { + // hard coded properties should exist + throw new OCSException($e->getMessage(), Http::STATUS_INTERNAL_SERVER_ERROR, $e); } $data['groups'] = $gids; |