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 /lib | |
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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Accounts/AccountManager.php | 35 | ||||
-rw-r--r-- | lib/private/Accounts/Hooks.php | 3 |
2 files changed, 35 insertions, 3 deletions
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; |