summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2021-06-22 18:42:39 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2021-06-30 00:47:43 +0200
commit02808e38b4a974b55d8c41b92599d9e13b954937 (patch)
tree0261f3f508e040b855960fca4aa0d1f2a17d5438 /apps/provisioning_api
parentc7bf4295cc98328796029e106b5881adfd9b2113 (diff)
downloadnextcloud-server-02808e38b4a974b55d8c41b92599d9e13b954937.tar.gz
nextcloud-server-02808e38b4a974b55d8c41b92599d9e13b954937.zip
create a property on editUser when it was not set before
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index 709f139d830..65789e14b7f 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -53,6 +53,7 @@ use OC\User\Backend;
use OCA\Settings\Mailer\NewUserMailHelper;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\IAccountProperty;
+use OCP\Accounts\PropertyDoesNotExistException;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -850,19 +851,22 @@ class UsersController extends AUserData {
case IAccountManager::PROPERTY_WEBSITE:
case IAccountManager::PROPERTY_TWITTER:
$userAccount = $this->accountManager->getAccount($targetUser);
- $userProperty = $userAccount->getProperty($key);
- if ($userProperty->getValue() !== $value) {
- try {
- $userProperty->setValue($value);
- $this->accountManager->updateAccount($userAccount);
-
- if ($userProperty->getName() === IAccountManager::PROPERTY_PHONE) {
- $this->knownUserService->deleteByContactUserId($targetUser->getUID());
+ try {
+ $userProperty = $userAccount->getProperty($key);
+ if ($userProperty->getValue() !== $value) {
+ try {
+ $userProperty->setValue($value);
+ if ($userProperty->getName() === IAccountManager::PROPERTY_PHONE) {
+ $this->knownUserService->deleteByContactUserId($targetUser->getUID());
+ }
+ } catch (\InvalidArgumentException $e) {
+ throw new OCSException('Invalid ' . $e->getMessage(), 102);
}
- } catch (\InvalidArgumentException $e) {
- throw new OCSException('Invalid ' . $e->getMessage(), 102);
}
+ } catch (PropertyDoesNotExistException $e) {
+ $userAccount->setProperty($key, $value, IAccountManager::SCOPE_PRIVATE, IAccountManager::NOT_VERIFIED);
}
+ $this->accountManager->updateAccount($userAccount);
break;
case IAccountManager::PROPERTY_DISPLAYNAME . self::SCOPE_SUFFIX:
case IAccountManager::PROPERTY_EMAIL . self::SCOPE_SUFFIX: