Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/User/VerifyJob.php
Show All 9 Lines | class VerifyJob extends UserJob | ||||
* Execute the job. | * Execute the job. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$user = $this->getUser(); | $user = $this->getUser(); | ||||
if (!$user) { | |||||
return; | |||||
} | |||||
// sanity checks | // sanity checks | ||||
if (!$user->hasSku('mailbox')) { | if (!$user->hasSku('mailbox')) { | ||||
$this->fail(new \Exception("User {$this->userId} has no mailbox SKU.")); | $this->fail(new \Exception("User {$this->userId} has no mailbox SKU.")); | ||||
return; | |||||
} | } | ||||
// the user has a mailbox (or is marked as such) | // the user has a mailbox (or is marked as such) | ||||
if ($user->isImapReady()) { | if ($user->isImapReady()) { | ||||
$this->fail(new \Exception("User {$this->userId} is already verified.")); | $this->fail(new \Exception("User {$this->userId} is already verified.")); | ||||
return; | |||||
} | } | ||||
if (\App\Backends\IMAP::verifyAccount($user->email)) { | if (\App\Backends\IMAP::verifyAccount($user->email)) { | ||||
$user->status |= \App\User::STATUS_IMAP_READY; | $user->status |= \App\User::STATUS_IMAP_READY; | ||||
$user->status |= \App\User::STATUS_ACTIVE; | $user->status |= \App\User::STATUS_ACTIVE; | ||||
$user->save(); | $user->save(); | ||||
} | } | ||||
} | } | ||||
} | } |