-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ProvisioningApi): only return verified additional mails per user
It would not per se be bad to return all of them, however the meta data about the verified state is missing. Since the information may go out to connected clients, those may have wrong trust the returned email addresses. Email verification still works with this change. Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
- Loading branch information
Showing
5 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
apps/testing/lib/Controller/MailVerificationTestController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
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
|
||
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
|
||
$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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters