fixed all tests
This commit is contained in:
@ -2,8 +2,8 @@
|
||||
namespace Da\User\Service;
|
||||
|
||||
use Da\User\Contracts\ServiceInterface;
|
||||
use yii\swiftmailer\Mailer;
|
||||
use Yii;
|
||||
use yii\mail\BaseMailer;
|
||||
|
||||
class MailService implements ServiceInterface
|
||||
{
|
||||
@ -24,9 +24,9 @@ class MailService implements ServiceInterface
|
||||
* @param string $subject
|
||||
* @param string $view
|
||||
* @param array $params
|
||||
* @param Mailer $mailer
|
||||
* @param MailerInterface $mailer
|
||||
*/
|
||||
public function __construct($from, $to, $subject, $view, array $params, Mailer $mailer)
|
||||
public function __construct($from, $to, $subject, $view, array $params, BaseMailer $mailer)
|
||||
{
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
@ -56,7 +56,8 @@ class MailService implements ServiceInterface
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
return $this->mailer->compose(['html' => $this->view, 'text' => "text/{$this->view}"], $this->params)
|
||||
return $this->mailer
|
||||
->compose(['html' => $this->view, 'text' => "text/{$this->view}"], $this->params)
|
||||
->setFrom($this->from)
|
||||
->setTo($this->to)
|
||||
->setSubject($this->subject)
|
||||
|
||||
@ -41,11 +41,15 @@ class PasswordRecoveryService implements ServiceInterface
|
||||
|
||||
$this->mailService->setViewParam('user', $user);
|
||||
$this->mailService->setViewParam('token', $token);
|
||||
|
||||
if (!$this->mailService->run()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Yii::$app->session->setFlash(
|
||||
'info',
|
||||
Yii::t('user', 'An email has been sent with instructions for resetting your password')
|
||||
);
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
@ -60,6 +60,7 @@ class UserCreateService implements ServiceInterface
|
||||
return true;
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
$transaction->rollBack();
|
||||
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
|
||||
|
||||
|
||||
@ -7,12 +7,14 @@ use Da\User\Factory\TokenFactory;
|
||||
use Da\User\Helper\SecurityHelper;
|
||||
use Da\User\Model\Token;
|
||||
use Da\User\Model\User;
|
||||
use Da\User\Traits\ModuleTrait;
|
||||
use yii\base\InvalidCallException;
|
||||
use yii\log\Logger;
|
||||
use Exception;
|
||||
|
||||
class UserRegisterService implements ServiceInterface
|
||||
{
|
||||
use ModuleTrait;
|
||||
|
||||
protected $model;
|
||||
protected $securityHelper;
|
||||
@ -38,8 +40,8 @@ class UserRegisterService implements ServiceInterface
|
||||
$transaction = $model->getDb()->beginTransaction();
|
||||
|
||||
try {
|
||||
$model->confirmed_at = $this->model->module->enableEmailConfirmation ? null : time();
|
||||
$model->password = $this->model->module->generatePasswords
|
||||
$model->confirmed_at = $this->getModule()->enableEmailConfirmation ? null : time();
|
||||
$model->password = $this->getModule()->generatePasswords
|
||||
? $this->securityHelper->generatePassword(8)
|
||||
: $model->password;
|
||||
|
||||
@ -50,7 +52,7 @@ class UserRegisterService implements ServiceInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
if($model->module->enableEmailConfirmation) {
|
||||
if($this->getModule()->enableEmailConfirmation) {
|
||||
$token = TokenFactory::makeConfirmationToken($model->id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user