added email change strategies

This commit is contained in:
Antonio Ramirez
2016-12-10 14:14:42 +01:00
parent 3fe09e3eb3
commit e215fd58bf
19 changed files with 626 additions and 119 deletions

View File

@ -0,0 +1,47 @@
<?php
namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface;
use Da\User\Event\UserEvent;
use Da\User\Model\Token;
use Da\User\Model\User;
use Da\User\Query\TokenQuery;
class AccountConfirmationService implements ServiceInterface
{
protected $model;
protected $code;
protected $tokenQuery;
protected $userConfirmationService;
public function __construct(
$code,
User $model,
TokenQuery $tokenQuery,
UserConfirmationService $userConfirmationService
) {
$this->code = $code;
$this->model = $model;
$this->tokenQuery = $tokenQuery;
$this->userConfirmationService = $userConfirmationService;
}
public function run()
{
$token = $this->tokenQuery
->whereUserId($this->model->id)
->whereCode($this->code)
->whereIsConfirmationType()
->one();
if ($token instanceof Token && !$token->getIsExpired()) {
$token->delete();
return $this->userConfirmationService->run();
}
return false;
}
}