-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ProvisioningApi): only return verified additional mails per user #44341
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,35 @@ | ||||||||||||||||
<?php | ||||||||||||||||
|
||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
namespace OCA\Testing\Controller; | ||||||||||||||||
|
||||||||||||||||
use InvalidArgumentException; | ||||||||||||||||
use OCP\Accounts\IAccountManager; | ||||||||||||||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired; | ||||||||||||||||
use OCP\AppFramework\Http\DataResponse; | ||||||||||||||||
use OCP\AppFramework\OCSController; | ||||||||||||||||
use OCP\IRequest; | ||||||||||||||||
use OCP\IUser; | ||||||||||||||||
use OCP\IUserManager; | ||||||||||||||||
|
||||||||||||||||
class MailVerificationTestController extends OCSController { | ||||||||||||||||
public function __construct( | ||||||||||||||||
$appName, | ||||||||||||||||
Check notice Code scanning / Psalm MissingParamType Note test
Parameter $appName has no provided type
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
IRequest $request, | ||||||||||||||||
protected IAccountManager $accountManager, | ||||||||||||||||
protected IUserManager $userManager, | ||||||||||||||||
) { | ||||||||||||||||
parent::__construct($appName, $request); | ||||||||||||||||
} | ||||||||||||||||
|
||||||||||||||||
public function verify(string $userId, string $email): DataResponse { | ||||||||||||||||
$user = $this->userManager->get($userId); | ||||||||||||||||
$userAccount = $this->accountManager->getAccount($user); | ||||||||||||||||
Check notice Code scanning / Psalm PossiblyNullArgument Note test
Argument 1 of OCP\Accounts\IAccountManager::getAccount cannot be null, possibly null value provided
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
$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(); | ||||||||||||||||
} | ||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,11 +129,13 @@ Feature: provisioning | |
| value | [email protected] | | ||
And the OCS status code should be "100" | ||
And the HTTP status code should be "200" | ||
And user "brand-new-user" verifies email "[email protected]" | ||
And sending "PUT" to "/cloud/users/brand-new-user" with | ||
| key | additional_mail | | ||
| value | [email protected] | | ||
And the OCS status code should be "100" | ||
And the HTTP status code should be "200" | ||
And user "brand-new-user" verifies email "[email protected]" | ||
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 | [email protected] | | ||
And the OCS status code should be "100" | ||
And the HTTP status code should be "200" | ||
And user "brand-new-user" verifies email "[email protected]" | ||
And sending "PUT" to "/cloud/users/brand-new-user" with | ||
| key | additional_mail | | ||
| value | [email protected] | | ||
And the OCS status code should be "100" | ||
And the HTTP status code should be "200" | ||
And user "brand-new-user" verifies email "[email protected]" | ||
When sending "PUT" to "/cloud/users/brand-new-user/additional_mail" with | ||
| key | [email protected] | | ||
| value | | | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs SPDX headers