From 1c0aae9c54a01c33cb32373b8a455b932ec25829 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Mar 2023 12:32:12 +0100 Subject: fix(provisioning_api): Don't allow to configure the same additional email multiple times Signed-off-by: Joas Schilling --- apps/provisioning_api/lib/Controller/UsersController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apps/provisioning_api/lib/Controller') diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index bc97e32faa4..b005acc4d7f 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -942,11 +942,11 @@ class UsersController extends AUserData { if (filter_var($value, FILTER_VALIDATE_EMAIL) && $value !== $targetUser->getSystemEMailAddress()) { $userAccount = $this->accountManager->getAccount($targetUser); $mailCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_EMAIL); - foreach ($mailCollection->getProperties() as $property) { - if ($property->getValue() === $value) { - break; - } + + if ($mailCollection->getPropertyByValue($value)) { + throw new OCSException('', 102); } + $mailCollection->addPropertyWithDefaults($value); $this->accountManager->updateAccount($userAccount); } else { -- cgit v1.2.3