re #108 use app main logger + multiple fixes
This commit is contained in:
@ -31,14 +31,14 @@ class AuthRuleEditionService implements ServiceInterface
|
||||
|
||||
public function run()
|
||||
{
|
||||
if (!$this->model->validate() || (!in_array($this->model->scenario, ['create', 'update']))) {
|
||||
if (!$this->model->validate() || (!in_array($this->model->scenario, ['create', 'update'], false))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$rule = $this->make($this->model->className, [], ['name' => $this->model->name]);
|
||||
|
||||
try {
|
||||
if ($this->model->scenario == 'create') {
|
||||
if ($this->model->scenario === 'create') {
|
||||
$this->getAuthManager()->add($rule);
|
||||
} else {
|
||||
$this->getAuthManager()->update($this->model->previousName, $rule);
|
||||
|
||||
@ -76,8 +76,8 @@ class EmailChangeService implements ServiceInterface
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_DEFAULT
|
||||
|| ($this->model->flags & User::NEW_EMAIL_CONFIRMED & $this->model->flags & User::OLD_EMAIL_CONFIRMED)
|
||||
if (($this->model->flags & User::NEW_EMAIL_CONFIRMED & $this->model->flags & User::OLD_EMAIL_CONFIRMED)
|
||||
|| $this->getModule()->emailChangeStrategy === MailChangeStrategyInterface::TYPE_DEFAULT
|
||||
) {
|
||||
$this->model->email = $this->model->unconfirmed_email;
|
||||
$this->model->unconfirmed_email = null;
|
||||
|
||||
@ -13,13 +13,11 @@ namespace Da\User\Service;
|
||||
|
||||
use Da\User\Contracts\ServiceInterface;
|
||||
use Da\User\Factory\TokenFactory;
|
||||
use Da\User\Model\Token;
|
||||
use Da\User\Model\User;
|
||||
use Da\User\Query\UserQuery;
|
||||
use Da\User\Traits\MailAwareTrait;
|
||||
use Exception;
|
||||
use Yii;
|
||||
use yii\log\Logger;
|
||||
|
||||
class PasswordRecoveryService implements ServiceInterface
|
||||
{
|
||||
@ -30,14 +28,12 @@ class PasswordRecoveryService implements ServiceInterface
|
||||
protected $email;
|
||||
protected $mailService;
|
||||
protected $securityHelper;
|
||||
protected $logger;
|
||||
|
||||
public function __construct($email, MailService $mailService, UserQuery $query, Logger $logger)
|
||||
public function __construct($email, MailService $mailService, UserQuery $query)
|
||||
{
|
||||
$this->email = $email;
|
||||
$this->mailService = $mailService;
|
||||
$this->query = $query;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -65,7 +61,7 @@ class PasswordRecoveryService implements ServiceInterface
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
|
||||
Yii::error($e->getMessage(), 'usuario');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@ use Da\User\Contracts\ServiceInterface;
|
||||
use Da\User\Factory\TokenFactory;
|
||||
use Da\User\Model\User;
|
||||
use Da\User\Traits\MailAwareTrait;
|
||||
use yii\log\Logger;
|
||||
|
||||
class ResendConfirmationService implements ServiceInterface
|
||||
{
|
||||
@ -23,13 +22,11 @@ class ResendConfirmationService implements ServiceInterface
|
||||
|
||||
protected $model;
|
||||
protected $mailService;
|
||||
protected $logger;
|
||||
|
||||
public function __construct(User $model, MailService $mailService, Logger $logger)
|
||||
public function __construct(User $model, MailService $mailService)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->mailService = $mailService;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -37,6 +34,7 @@ class ResendConfirmationService implements ServiceInterface
|
||||
if ($this->model && !$this->model->getIsConfirmed()) {
|
||||
$token = TokenFactory::makeConfirmationToken($this->model->id);
|
||||
$this->mailService->setViewParam('token', $token);
|
||||
|
||||
return $this->sendMail($this->model);
|
||||
}
|
||||
|
||||
|
||||
@ -47,8 +47,7 @@ class TwoFactorQrCodeUriGeneratorService implements ServiceInterface
|
||||
}
|
||||
|
||||
$totpUri = (new TOTPSecretKeyUriGeneratorService(Yii::$app->name, $user->email, $user->auth_tf_key))->run();
|
||||
$dataUri = (new QrCodeDataUriGeneratorService($totpUri))->run();
|
||||
|
||||
return $dataUri;
|
||||
return (new QrCodeDataUriGeneratorService($totpUri))->run();
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ use Da\User\Traits\MailAwareTrait;
|
||||
use Exception;
|
||||
use Yii;
|
||||
use yii\base\InvalidCallException;
|
||||
use yii\log\Logger;
|
||||
|
||||
class UserCreateService implements ServiceInterface
|
||||
{
|
||||
@ -28,18 +27,19 @@ class UserCreateService implements ServiceInterface
|
||||
protected $model;
|
||||
protected $securityHelper;
|
||||
protected $mailService;
|
||||
protected $logger;
|
||||
|
||||
public function __construct(User $model, MailService $mailService, SecurityHelper $securityHelper, Logger $logger)
|
||||
public function __construct(User $model, MailService $mailService, SecurityHelper $securityHelper)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->mailService = $mailService;
|
||||
$this->securityHelper = $securityHelper;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*
|
||||
* @throws InvalidCallException
|
||||
* @throws \yii\db\Exception
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
@ -49,7 +49,7 @@ class UserCreateService implements ServiceInterface
|
||||
throw new InvalidCallException('Cannot create a new user from an existing one.');
|
||||
}
|
||||
|
||||
$transaction = $model->getDb()->beginTransaction();
|
||||
$transaction = $model::getDb()->beginTransaction();
|
||||
|
||||
try {
|
||||
$model->confirmed_at = time();
|
||||
@ -81,7 +81,7 @@ class UserCreateService implements ServiceInterface
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$transaction->rollBack();
|
||||
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
|
||||
Yii::error($e->getMessage(), 'usuario');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ use Da\User\Traits\MailAwareTrait;
|
||||
use Da\User\Traits\ModuleAwareTrait;
|
||||
use Exception;
|
||||
use yii\base\InvalidCallException;
|
||||
use yii\log\Logger;
|
||||
use Yii;
|
||||
|
||||
class UserRegisterService implements ServiceInterface
|
||||
@ -31,14 +30,12 @@ class UserRegisterService implements ServiceInterface
|
||||
protected $model;
|
||||
protected $securityHelper;
|
||||
protected $mailService;
|
||||
protected $logger;
|
||||
|
||||
public function __construct(User $model, MailService $mailService, SecurityHelper $securityHelper, Logger $logger)
|
||||
public function __construct(User $model, MailService $mailService, SecurityHelper $securityHelper)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->mailService = $mailService;
|
||||
$this->securityHelper = $securityHelper;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -49,7 +46,7 @@ class UserRegisterService implements ServiceInterface
|
||||
throw new InvalidCallException('Cannot register user from an existing one.');
|
||||
}
|
||||
|
||||
$transaction = $model->getDb()->beginTransaction();
|
||||
$transaction = $model::getDb()->beginTransaction();
|
||||
|
||||
try {
|
||||
$model->confirmed_at = $this->getModule()->enableEmailConfirmation ? null : time();
|
||||
@ -91,7 +88,7 @@ class UserRegisterService implements ServiceInterface
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$transaction->rollBack();
|
||||
$this->logger->log($e->getMessage(), Logger::LEVEL_ERROR);
|
||||
Yii::error($e->getMessage(), 'usuario');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user