ask lookup server if email address was verified by the user
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
86701dce7b
commit
7c309c253b
|
@ -33,7 +33,11 @@ $dispatcher->addListener('OC\AccountManager::userUpdated', function(\Symfony\Com
|
|||
$lookupServer = $config->getSystemValue('lookup_server', '');
|
||||
|
||||
$updateLookupServer = new \OCA\LookupServerConnector\UpdateLookupServer(
|
||||
new \OC\Accounts\AccountManager(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()),
|
||||
new \OC\Accounts\AccountManager(
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
\OC::$server->getEventDispatcher(),
|
||||
\OC::$server->getJobList()
|
||||
),
|
||||
\OC::$server->getHTTPClientService(),
|
||||
new \OC\Security\IdentityProof\Signer(
|
||||
$keyManager,
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
namespace OC\Accounts;
|
||||
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUser;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
@ -66,15 +67,22 @@ class AccountManager {
|
|||
/** @var EventDispatcherInterface */
|
||||
private $eventDispatcher;
|
||||
|
||||
/** @var IJobList */
|
||||
private $jobList;
|
||||
|
||||
/**
|
||||
* AccountManager constructor.
|
||||
*
|
||||
* @param IDBConnection $connection
|
||||
* @param EventDispatcherInterface $eventDispatcher
|
||||
* @param IJobList $jobList
|
||||
*/
|
||||
public function __construct(IDBConnection $connection, EventDispatcherInterface $eventDispatcher) {
|
||||
public function __construct(IDBConnection $connection,
|
||||
EventDispatcherInterface $eventDispatcher,
|
||||
IJobList $jobList) {
|
||||
$this->connection = $connection;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
$this->jobList = $jobList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,6 +97,7 @@ class AccountManager {
|
|||
if (empty($userData)) {
|
||||
$this->insertNewUser($user, $data);
|
||||
} elseif ($userData !== $data) {
|
||||
$this->checkEmailVerification($userData, $data, $user);
|
||||
$data = $this->updateVerifyStatus($userData, $data);
|
||||
$this->updateExistingUser($user, $data);
|
||||
} else {
|
||||
|
@ -128,6 +137,28 @@ class AccountManager {
|
|||
return json_decode($result[0]['data'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* check if we need to ask the server for email verification, if yes we create a cronjob
|
||||
*
|
||||
* @param $oldData
|
||||
* @param $newData
|
||||
* @param IUser $user
|
||||
*/
|
||||
protected function checkEmailVerification($oldData, $newData, IUser $user) {
|
||||
if ($oldData[self::PROPERTY_EMAIL]['value'] !== $newData[self::PROPERTY_EMAIL]['value']) {
|
||||
$this->jobList->add('OC\Settings\BackgroundJobs\VerifyUserData',
|
||||
[
|
||||
'verificationCode' => '',
|
||||
'data' => $newData[self::PROPERTY_EMAIL]['value'],
|
||||
'type' => self::PROPERTY_EMAIL,
|
||||
'uid' => $user->getUID(),
|
||||
'try' => 0,
|
||||
'lastRun' => time()
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* reset verification status if personal data changed
|
||||
*
|
||||
|
@ -152,7 +183,7 @@ class AccountManager {
|
|||
}
|
||||
|
||||
if(!isset($newData[self::PROPERTY_EMAIL]['verified'])) {
|
||||
$newData[self::PROPERTY_EMAIL]['verified'] = isset($oldData[self::PROPERTY_WEBSITE]['verified']) ? $oldData[self::PROPERTY_EMAIL]['verified'] : self::NOT_VERIFIED;
|
||||
$newData[self::PROPERTY_EMAIL]['verified'] = isset($oldData[self::PROPERTY_WEBSITE]['verified']) ? $oldData[self::PROPERTY_EMAIL]['verified'] : self::VERIFICATION_IN_PROGRESS;
|
||||
}
|
||||
|
||||
// reset verification status if a value from a previously verified data was changed
|
||||
|
|
|
@ -89,7 +89,8 @@ class Hooks {
|
|||
if (is_null($this->accountManager)) {
|
||||
$this->accountManager = new AccountManager(
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
\OC::$server->getEventDispatcher()
|
||||
\OC::$server->getEventDispatcher(),
|
||||
\OC::$server->getJobList()
|
||||
);
|
||||
}
|
||||
return $this->accountManager;
|
||||
|
|
|
@ -40,7 +40,11 @@ OC_Util::checkLoggedIn();
|
|||
|
||||
$defaults = \OC::$server->getThemingDefaults();
|
||||
$certificateManager = \OC::$server->getCertificateManager();
|
||||
$accountManager = new \OC\Accounts\AccountManager(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher());
|
||||
$accountManager = new \OC\Accounts\AccountManager(
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
\OC::$server->getEventDispatcher(),
|
||||
\OC::$server->getJobList()
|
||||
);
|
||||
$config = \OC::$server->getConfig();
|
||||
$urlGenerator = \OC::$server->getURLGenerator();
|
||||
|
||||
|
|
Loading…
Reference in New Issue