diff --git a/apps/provisioning_api/lib/Controller/AUserData.php b/apps/provisioning_api/lib/Controller/AUserData.php index d7db48dc33f94..ac65c63061f30 100644 --- a/apps/provisioning_api/lib/Controller/AUserData.php +++ b/apps/provisioning_api/lib/Controller/AUserData.php @@ -149,6 +149,9 @@ protected function getUserData(string $userId, bool $includeScopes = false): ?ar $additionalEmails = $additionalEmailScopes = []; $emailCollection = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_EMAIL); foreach ($emailCollection->getProperties() as $property) { + if ($property->getLocallyVerified() !== IAccountManager::VERIFIED) { + continue; + } $additionalEmails[] = $property->getValue(); if ($includeScopes) { $additionalEmailScopes[] = $property->getScope(); diff --git a/apps/testing/appinfo/routes.php b/apps/testing/appinfo/routes.php index 862f63ef4c2fb..1c89b474838fc 100644 --- a/apps/testing/appinfo/routes.php +++ b/apps/testing/appinfo/routes.php @@ -63,5 +63,10 @@ 'type' => null ] ], + [ + 'name' => 'MailVerificationTest', + 'url' => '/api/v1/mailverification', + 'verb' => 'POST', + ] ], ]; diff --git a/apps/testing/lib/Controller/MailVerificationTestController.php b/apps/testing/lib/Controller/MailVerificationTestController.php new file mode 100644 index 0000000000000..95590117fb89b --- /dev/null +++ b/apps/testing/lib/Controller/MailVerificationTestController.php @@ -0,0 +1,35 @@ +userManager->get($userId); + $userAccount = $this->accountManager->getAccount($user); + $emailProperty = $userAccount->getPropertyCollection(IAccountManager::COLLECTION_EMAIL) + ->getPropertyByValue($email); + if ($emailProperty === null) { + throw new InvalidArgumentException('Email not available in account.'); + } + $emailProperty->setLocallyVerified(IAccountManager::VERIFIED); + return new DataResponse(); + } +} diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index 2fb1c807cc551..b3e3019a4c860 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -980,4 +980,28 @@ public function userHasNotSetting($user, \Behat\Gherkin\Node\TableNode $settings } } } + + /** + * @Then user :user verifies email :email + */ + public function userVerifiesEmail(string $userId, string $email): void { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/testing/api/v1/mailverification"; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } + + $options['form_params'] = [ + 'userid' => $userId, + 'email' => $email, + ]; + + $options['headers'] = [ + 'OCS-APIREQUEST' => 'true', + ]; + + $this->response = $client->post($fullUrl, $options); + } } + diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature index 2238c82093984..35b64bb8c4396 100644 --- a/build/integration/features/provisioning-v1.feature +++ b/build/integration/features/provisioning-v1.feature @@ -129,11 +129,13 @@ Feature: provisioning | value | no.reply@nextcloud.com | And the OCS status code should be "100" And the HTTP status code should be "200" + And user "brand-new-user" verifies email "no.reply@nextcloud.com" And sending "PUT" to "/cloud/users/brand-new-user" with | key | additional_mail | | value | noreply@nextcloud.com | And the OCS status code should be "100" And the HTTP status code should be "200" + And user "brand-new-user" verifies email "noreply@nextcloud.com" And sending "PUT" to "/cloud/users/brand-new-user" with | key | phone | | value | +49 711 / 25 24 28-90 | @@ -302,11 +304,13 @@ Feature: provisioning | value | no.reply6@nextcloud.com | And the OCS status code should be "100" And the HTTP status code should be "200" + And user "brand-new-user" verifies email "no.reply6@nextcloud.com" And sending "PUT" to "/cloud/users/brand-new-user" with | key | additional_mail | | value | noreply7@nextcloud.com | And the OCS status code should be "100" And the HTTP status code should be "200" + And user "brand-new-user" verifies email "no.reply7@nextcloud.com" When sending "PUT" to "/cloud/users/brand-new-user/additional_mail" with | key | no.reply6@nextcloud.com | | value | |