diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-04-21 17:36:03 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-04-28 23:41:36 -0300 |
commit | 7c309c253be8f8543627436cb5fe60421860593c (patch) | |
tree | 50c16e8936a2172c6d33a314184c903b5deed352 | |
parent | 86701dce7b041f9ef9d5802475c360f3e0a0ca6a (diff) | |
download | nextcloud-server-7c309c253be8f8543627436cb5fe60421860593c.tar.gz nextcloud-server-7c309c253be8f8543627436cb5fe60421860593c.zip |
ask lookup server if email address was verified by the user
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
-rw-r--r-- | apps/lookup_server_connector/appinfo/app.php | 6 | ||||
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 35 | ||||
-rw-r--r-- | lib/private/Accounts/Hooks.php | 3 | ||||
-rw-r--r-- | settings/personal.php | 6 |
4 files changed, 45 insertions, 5 deletions
diff --git a/apps/lookup_server_connector/appinfo/app.php b/apps/lookup_server_connector/appinfo/app.php index a98a5de406f..f0d624d5f3a 100644 --- a/apps/lookup_server_connector/appinfo/app.php +++ b/apps/lookup_server_connector/appinfo/app.php @@ -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, diff --git a/lib/private/Accounts/AccountManager.php b/lib/private/Accounts/AccountManager.php index 0c175795541..cc65ae8caa1 100644 --- a/lib/private/Accounts/AccountManager.php +++ b/lib/private/Accounts/AccountManager.php @@ -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 { @@ -129,6 +138,28 @@ class AccountManager { } /** + * 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 * * @param array $oldData @@ -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 diff --git a/lib/private/Accounts/Hooks.php b/lib/private/Accounts/Hooks.php index 38e7e20485b..eca56913fbd 100644 --- a/lib/private/Accounts/Hooks.php +++ b/lib/private/Accounts/Hooks.php @@ -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; diff --git a/settings/personal.php b/settings/personal.php index 6cbcc330cd9..6fbe95f9ea7 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -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(); |