PHP-CS-Fixer run
This commit is contained in:
@ -27,9 +27,9 @@ use yii\base\Event as YiiEvent;
|
|||||||
use yii\base\Exception;
|
use yii\base\Exception;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\console\Application as ConsoleApplication;
|
use yii\console\Application as ConsoleApplication;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\i18n\PhpMessageSource;
|
use yii\i18n\PhpMessageSource;
|
||||||
use yii\web\Application as WebApplication;
|
use yii\web\Application as WebApplication;
|
||||||
use yii\helpers\ArrayHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap class of the yii2-usuario extension. Configures container services, initializes translations,
|
* Bootstrap class of the yii2-usuario extension. Configures container services, initializes translations,
|
||||||
@ -195,7 +195,9 @@ class Bootstrap implements BootstrapInterface
|
|||||||
];
|
];
|
||||||
|
|
||||||
$app->getModule('user')->twoFactorAuthenticationValidators = ArrayHelper::merge(
|
$app->getModule('user')->twoFactorAuthenticationValidators = ArrayHelper::merge(
|
||||||
$defaultTwoFactorAuthenticationValidators, $app->getModule('user')->twoFactorAuthenticationValidators);
|
$defaultTwoFactorAuthenticationValidators,
|
||||||
|
$app->getModule('user')->twoFactorAuthenticationValidators
|
||||||
|
);
|
||||||
|
|
||||||
if ($app instanceof WebApplication) {
|
if ($app instanceof WebApplication) {
|
||||||
// override Yii
|
// override Yii
|
||||||
@ -208,11 +210,6 @@ class Bootstrap implements BootstrapInterface
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
die($e);
|
die($e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -357,6 +357,7 @@ class AdminController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display list session history
|
* Display list session history
|
||||||
|
* @param mixed $id
|
||||||
*/
|
*/
|
||||||
public function actionSessionHistory($id)
|
public function actionSessionHistory($id)
|
||||||
{
|
{
|
||||||
@ -376,6 +377,7 @@ class AdminController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate all session user
|
* Terminate all session user
|
||||||
|
* @param mixed $id
|
||||||
*/
|
*/
|
||||||
public function actionTerminateSessions($id)
|
public function actionTerminateSessions($id)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* This file is part of the 2amigos/yii2-usuario project.
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* (c) 2amigOS! <http://2amigos.us/>
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
@ -15,6 +15,7 @@ use Da\User\Contracts\AuthClientInterface;
|
|||||||
use Da\User\Event\FormEvent;
|
use Da\User\Event\FormEvent;
|
||||||
use Da\User\Event\UserEvent;
|
use Da\User\Event\UserEvent;
|
||||||
use Da\User\Form\LoginForm;
|
use Da\User\Form\LoginForm;
|
||||||
|
use Da\User\Model\User;
|
||||||
use Da\User\Query\SocialNetworkAccountQuery;
|
use Da\User\Query\SocialNetworkAccountQuery;
|
||||||
use Da\User\Service\SocialNetworkAccountConnectService;
|
use Da\User\Service\SocialNetworkAccountConnectService;
|
||||||
use Da\User\Service\SocialNetworkAuthenticateService;
|
use Da\User\Service\SocialNetworkAuthenticateService;
|
||||||
@ -22,7 +23,6 @@ use Da\User\Traits\ContainerAwareTrait;
|
|||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\TwoFactorEmailValidator;
|
use Da\User\Validator\TwoFactorEmailValidator;
|
||||||
use Da\User\Validator\TwoFactorTextMessageValidator;
|
use Da\User\Validator\TwoFactorTextMessageValidator;
|
||||||
use Da\User\Model\User;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\authclient\AuthAction;
|
use yii\authclient\AuthAction;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
@ -30,10 +30,10 @@ use yii\base\InvalidParamException;
|
|||||||
use yii\base\Module;
|
use yii\base\Module;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\Response;
|
use yii\web\Response;
|
||||||
use yii\widgets\ActiveForm;
|
use yii\widgets\ActiveForm;
|
||||||
use yii\helpers\ArrayHelper;
|
|
||||||
|
|
||||||
class SecurityController extends Controller
|
class SecurityController extends Controller
|
||||||
{
|
{
|
||||||
@ -216,8 +216,7 @@ class SecurityController extends Controller
|
|||||||
|
|
||||||
return $this->goBack();
|
return $this->goBack();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$module = Yii::$app->getModule('user');
|
$module = Yii::$app->getModule('user');
|
||||||
$validators = $module->twoFactorAuthenticationValidators;
|
$validators = $module->twoFactorAuthenticationValidators;
|
||||||
$credentials = Yii::$app->session->get('credentials');
|
$credentials = Yii::$app->session->get('credentials');
|
||||||
@ -233,7 +232,6 @@ class SecurityController extends Controller
|
|||||||
->make($class, [$user, null, $this->module->twoFactorAuthenticationCycles]);
|
->make($class, [$user, null, $this->module->twoFactorAuthenticationCycles]);
|
||||||
|
|
||||||
$object->generateCode();
|
$object->generateCode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
@ -273,5 +271,4 @@ class SecurityController extends Controller
|
|||||||
|
|
||||||
$this->make(SocialNetworkAccountConnectService::class, [$this, $client])->run();
|
$this->make(SocialNetworkAccountConnectService::class, [$this, $client])->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* This file is part of the 2amigos/yii2-usuario project.
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
*
|
*
|
||||||
* (c) 2amigOS! <http://2amigos.us/>
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
@ -29,8 +29,8 @@ use Da\User\Query\UserQuery;
|
|||||||
use Da\User\Search\SessionHistorySearch;
|
use Da\User\Search\SessionHistorySearch;
|
||||||
use Da\User\Service\EmailChangeService;
|
use Da\User\Service\EmailChangeService;
|
||||||
use Da\User\Service\SessionHistory\TerminateUserSessionsService;
|
use Da\User\Service\SessionHistory\TerminateUserSessionsService;
|
||||||
use Da\User\Service\TwoFactorQrCodeUriGeneratorService;
|
|
||||||
use Da\User\Service\TwoFactorEmailCodeGeneratorService;
|
use Da\User\Service\TwoFactorEmailCodeGeneratorService;
|
||||||
|
use Da\User\Service\TwoFactorQrCodeUriGeneratorService;
|
||||||
use Da\User\Service\TwoFactorSmsCodeGeneratorService;
|
use Da\User\Service\TwoFactorSmsCodeGeneratorService;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
@ -564,36 +564,6 @@ class SettingsController extends Controller
|
|||||||
return $this->redirect(['session-history']);
|
return $this->redirect(['session-history']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $id
|
|
||||||
* @throws ForbiddenHttpException
|
|
||||||
* @throws NotFoundHttpException
|
|
||||||
* @throws \Exception
|
|
||||||
* @throws \Throwable
|
|
||||||
* @throws \yii\db\StaleObjectException
|
|
||||||
*/
|
|
||||||
protected function disconnectSocialNetwork($id)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var SocialNetworkAccount $account
|
|
||||||
*/
|
|
||||||
$account = $this->socialNetworkAccountQuery->whereId($id)->one();
|
|
||||||
|
|
||||||
if ($account === null) {
|
|
||||||
throw new NotFoundHttpException();
|
|
||||||
}
|
|
||||||
if ($account->user_id !== Yii::$app->user->id) {
|
|
||||||
throw new ForbiddenHttpException();
|
|
||||||
}
|
|
||||||
$event = $this->make(SocialNetworkConnectEvent::class, [Yii::$app->user->identity, $account]);
|
|
||||||
|
|
||||||
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_DISCONNECT, $event);
|
|
||||||
$account->delete();
|
|
||||||
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT, $event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function actionTwoFactorMobilePhone($id)
|
public function actionTwoFactorMobilePhone($id)
|
||||||
{
|
{
|
||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
@ -628,4 +598,34 @@ class SettingsController extends Controller
|
|||||||
: Yii::t('usuario', 'Error while enabling SMS two factor authentication. Please reload the page.'),
|
: Yii::t('usuario', 'Error while enabling SMS two factor authentication. Please reload the page.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @throws ForbiddenHttpException
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \Throwable
|
||||||
|
* @throws \yii\db\StaleObjectException
|
||||||
|
*/
|
||||||
|
protected function disconnectSocialNetwork($id)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @var SocialNetworkAccount $account
|
||||||
|
*/
|
||||||
|
$account = $this->socialNetworkAccountQuery->whereId($id)->one();
|
||||||
|
|
||||||
|
if ($account === null) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
if ($account->user_id !== Yii::$app->user->id) {
|
||||||
|
throw new ForbiddenHttpException();
|
||||||
|
}
|
||||||
|
$event = $this->make(SocialNetworkConnectEvent::class, [Yii::$app->user->identity, $account]);
|
||||||
|
|
||||||
|
$this->trigger(SocialNetworkConnectEvent::EVENT_BEFORE_DISCONNECT, $event);
|
||||||
|
$account->delete();
|
||||||
|
$this->trigger(SocialNetworkConnectEvent::EVENT_AFTER_DISCONNECT, $event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,10 +13,9 @@ namespace Da\User\Filter;
|
|||||||
|
|
||||||
use Da\User\Model\User;
|
use Da\User\Model\User;
|
||||||
use Da\User\Module;
|
use Da\User\Module;
|
||||||
|
use Da\User\Traits\AuthManagerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\ActionFilter;
|
use yii\base\ActionFilter;
|
||||||
use Da\User\Traits\AuthManagerAwareTrait;
|
|
||||||
|
|
||||||
|
|
||||||
class TwoFactorAuthenticationEnforceFilter extends ActionFilter
|
class TwoFactorAuthenticationEnforceFilter extends ActionFilter
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,8 +14,8 @@ namespace Da\User\Form;
|
|||||||
use Da\User\Helper\SecurityHelper;
|
use Da\User\Helper\SecurityHelper;
|
||||||
use Da\User\Model\User;
|
use Da\User\Model\User;
|
||||||
use Da\User\Query\UserQuery;
|
use Da\User\Query\UserQuery;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Da\User\Validator\TwoFactorCodeValidator;
|
use Da\User\Validator\TwoFactorCodeValidator;
|
||||||
use Da\User\Validator\TwoFactorEmailValidator;
|
use Da\User\Validator\TwoFactorEmailValidator;
|
||||||
use Da\User\Validator\TwoFactorTextMessageValidator;
|
use Da\User\Validator\TwoFactorTextMessageValidator;
|
||||||
@ -112,7 +112,6 @@ class LoginForm extends Model
|
|||||||
'twoFactorAuthenticationCodeValidate' => [
|
'twoFactorAuthenticationCodeValidate' => [
|
||||||
'twoFactorAuthenticationCode',
|
'twoFactorAuthenticationCode',
|
||||||
function ($attribute) {
|
function ($attribute) {
|
||||||
|
|
||||||
if ($this->user === null) {
|
if ($this->user === null) {
|
||||||
$this->addError($attribute, Yii::t('usuario', 'Invalid two factor authentication code'));
|
$this->addError($attribute, Yii::t('usuario', 'Invalid two factor authentication code'));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -14,7 +14,6 @@ namespace Da\User\Migration\Session;
|
|||||||
use Da\User\Helper\MigrationHelper;
|
use Da\User\Helper\MigrationHelper;
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
|
||||||
class m000000_000001_create_session_history_table extends Migration
|
class m000000_000001_create_session_history_table extends Migration
|
||||||
{
|
{
|
||||||
const SESSION_HISTORY_TABLE = '{{%session_history}}';
|
const SESSION_HISTORY_TABLE = '{{%session_history}}';
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the 2amigos/yii2-usuario project.
|
||||||
|
*
|
||||||
|
* (c) 2amigOS! <http://2amigos.us/>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Da\User\Migration;
|
namespace Da\User\Migration;
|
||||||
|
|
||||||
use yii\db\Migration;
|
use yii\db\Migration;
|
||||||
@ -16,7 +25,6 @@ class m000000_000010_add_auth_tf_type_auth_tf_mobile_phone_columns_to_user_table
|
|||||||
{
|
{
|
||||||
$this->addColumn('{{%user}}', 'auth_tf_type', $this->string(20)->after('auth_tf_enabled')->null());
|
$this->addColumn('{{%user}}', 'auth_tf_type', $this->string(20)->after('auth_tf_enabled')->null());
|
||||||
$this->addColumn('{{%user}}', 'auth_tf_mobile_phone', $this->string(20)->after('auth_tf_type')->null());
|
$this->addColumn('{{%user}}', 'auth_tf_mobile_phone', $this->string(20)->after('auth_tf_type')->null());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -16,8 +16,8 @@ use Da\User\Query\SessionHistoryQuery;
|
|||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\behaviors\TimestampBehavior;
|
use yii\behaviors\TimestampBehavior;
|
||||||
use yii\db\ActiveRecord;
|
|
||||||
use yii\db\ActiveQuery;
|
use yii\db\ActiveQuery;
|
||||||
|
use yii\db\ActiveRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $user_id
|
* @property int $user_id
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
namespace Da\User\Query;
|
namespace Da\User\Query;
|
||||||
|
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use yii\web\Session;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\web\Session;
|
||||||
|
|
||||||
class SessionHistoryCondition
|
class SessionHistoryCondition
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
namespace Da\User\Query;
|
namespace Da\User\Query;
|
||||||
|
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use yii\db\ActiveQuery;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\db\ActiveQuery;
|
||||||
|
|
||||||
class SessionHistoryQuery extends ActiveQuery
|
class SessionHistoryQuery extends ActiveQuery
|
||||||
{
|
{
|
||||||
@ -34,7 +34,6 @@ class SessionHistoryQuery extends ActiveQuery
|
|||||||
return $this->andWhere($this->getCondition()->inactive($userId));
|
return $this->andWhere($this->getCondition()->inactive($userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function whereExpired($userId)
|
public function whereExpired($userId)
|
||||||
{
|
{
|
||||||
return $this->andWhere($this->getCondition()->expired($userId));
|
return $this->andWhere($this->getCondition()->expired($userId));
|
||||||
|
|||||||
@ -17,7 +17,6 @@ use yii\base\InvalidConfigException;
|
|||||||
use yii\base\InvalidParamException;
|
use yii\base\InvalidParamException;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
|
|
||||||
|
|
||||||
class SessionHistorySearch extends SessionHistory
|
class SessionHistorySearch extends SessionHistory
|
||||||
{
|
{
|
||||||
use ContainerAwareTrait;
|
use ContainerAwareTrait;
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Da\User\Service\SessionHistory;
|
namespace Da\User\Service\SessionHistory;
|
||||||
|
|
||||||
|
|
||||||
use yii\web\DbSession;
|
use yii\web\DbSession;
|
||||||
|
|
||||||
class DBTerminateSessionsService implements TerminateSessionsServiceInterface
|
class DBTerminateSessionsService implements TerminateSessionsServiceInterface
|
||||||
|
|||||||
@ -16,9 +16,9 @@ use Da\User\Query\SessionHistoryCondition;
|
|||||||
use Da\User\Query\SessionHistoryQuery;
|
use Da\User\Query\SessionHistoryQuery;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\base\InvalidArgumentException as BaseInvalidArgumentException;
|
||||||
use yii\db\Exception;
|
use yii\db\Exception;
|
||||||
use yii\web\Session;
|
use yii\web\Session;
|
||||||
use yii\base\InvalidArgumentException as BaseInvalidArgumentException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decorator for the {@see Session} class for storing the 'session history'
|
* Decorator for the {@see Session} class for storing the 'session history'
|
||||||
@ -255,7 +255,6 @@ class SessionHistoryDecorator extends Session
|
|||||||
return $result;
|
return $result;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
@ -405,8 +404,8 @@ class SessionHistoryDecorator extends Session
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @return bool
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function unbindSessionHistory($id)
|
protected function unbindSessionHistory($id)
|
||||||
{
|
{
|
||||||
@ -420,8 +419,8 @@ class SessionHistoryDecorator extends Session
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param int $userId
|
* @param int $userId
|
||||||
* @return bool
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function displacementHistory($userId)
|
protected function displacementHistory($userId)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Da\User\Service\SessionHistory;
|
namespace Da\User\Service\SessionHistory;
|
||||||
|
|
||||||
|
|
||||||
class TerminateSessionsService implements TerminateSessionsServiceInterface
|
class TerminateSessionsService implements TerminateSessionsServiceInterface
|
||||||
{
|
{
|
||||||
protected $sessionIds;
|
protected $sessionIds;
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Da\User\Service\SessionHistory;
|
namespace Da\User\Service\SessionHistory;
|
||||||
|
|
||||||
|
|
||||||
use Da\User\Contracts\ServiceInterface;
|
use Da\User\Contracts\ServiceInterface;
|
||||||
|
|
||||||
interface TerminateSessionsServiceInterface extends ServiceInterface
|
interface TerminateSessionsServiceInterface extends ServiceInterface
|
||||||
|
|||||||
@ -11,15 +11,14 @@
|
|||||||
|
|
||||||
namespace Da\User\Service\SessionHistory;
|
namespace Da\User\Service\SessionHistory;
|
||||||
|
|
||||||
|
|
||||||
use Da\User\Contracts\ServiceInterface;
|
use Da\User\Contracts\ServiceInterface;
|
||||||
use Da\User\Event\SessionEvent;
|
use Da\User\Event\SessionEvent;
|
||||||
use Da\User\Model\SessionHistory;
|
use Da\User\Model\SessionHistory;
|
||||||
use Da\User\Model\User;
|
use Da\User\Model\User;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Da\User\Traits\ModuleAwareTrait;
|
use Da\User\Traits\ModuleAwareTrait;
|
||||||
use yii\web\Session;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\web\Session;
|
||||||
|
|
||||||
class TerminateUserSessionsService implements ServiceInterface
|
class TerminateUserSessionsService implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,9 +13,8 @@ namespace Da\User\Service;
|
|||||||
|
|
||||||
use Da\TwoFA\Manager;
|
use Da\TwoFA\Manager;
|
||||||
use Da\User\Contracts\ServiceInterface;
|
use Da\User\Contracts\ServiceInterface;
|
||||||
use Da\User\Model\User;
|
|
||||||
use Da\User\Factory\MailFactory;
|
use Da\User\Factory\MailFactory;
|
||||||
|
use Da\User\Model\User;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
|
||||||
class TwoFactorEmailCodeGeneratorService implements ServiceInterface
|
class TwoFactorEmailCodeGeneratorService implements ServiceInterface
|
||||||
@ -54,11 +53,11 @@ class TwoFactorEmailCodeGeneratorService implements ServiceInterface
|
|||||||
if (!$mailService->run()) {
|
if (!$mailService->run()) {
|
||||||
Yii::$app->session->addFlash('error', Yii::t('usuario', 'The email sending failed, please check your configuration.'));
|
Yii::$app->session->addFlash('error', Yii::t('usuario', 'The email sending failed, please check your configuration.'));
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}
|
||||||
// put key in session
|
// put key in session
|
||||||
Yii::$app->session->set("email_code_time", date('Y-m-d H:i:s'));
|
Yii::$app->session->set("email_code_time", date('Y-m-d H:i:s'));
|
||||||
Yii::$app->session->set("email_code", $code);
|
Yii::$app->session->set("email_code", $code);
|
||||||
}
|
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,13 +13,12 @@ namespace Da\User\Service;
|
|||||||
|
|
||||||
use Da\TwoFA\Manager;
|
use Da\TwoFA\Manager;
|
||||||
use Da\User\Contracts\ServiceInterface;
|
use Da\User\Contracts\ServiceInterface;
|
||||||
use Da\User\Model\User;
|
|
||||||
use Da\User\Factory\MailFactory;
|
use Da\User\Factory\MailFactory;
|
||||||
use yii\di\Instance;
|
use Da\User\Model\User;
|
||||||
use yetopen\smssender\SmsSenderInterface;
|
use yetopen\smssender\SmsSenderInterface;
|
||||||
use yii\helpers\ArrayHelper;
|
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\di\Instance;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
class TwoFactorSmsCodeGeneratorService implements ServiceInterface
|
class TwoFactorSmsCodeGeneratorService implements ServiceInterface
|
||||||
{
|
{
|
||||||
|
|||||||
@ -15,8 +15,8 @@ use Da\TwoFA\Exception\InvalidSecretKeyException;
|
|||||||
use Da\TwoFA\Manager;
|
use Da\TwoFA\Manager;
|
||||||
use Da\User\Contracts\ValidatorInterface;
|
use Da\User\Contracts\ValidatorInterface;
|
||||||
use Da\User\Model\User;
|
use Da\User\Model\User;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
|
||||||
use Da\User\Service\TwoFactorQrCodeUriGeneratorService;
|
use Da\User\Service\TwoFactorQrCodeUriGeneratorService;
|
||||||
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
|
|
||||||
class TwoFactorCodeValidator implements ValidatorInterface
|
class TwoFactorCodeValidator implements ValidatorInterface
|
||||||
@ -71,8 +71,9 @@ class TwoFactorCodeValidator implements ValidatorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
|
* @param mixed $codeDurationTime
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUnsuccessMessage($codeDurationTime)
|
public function getUnsuccessMessage($codeDurationTime)
|
||||||
{
|
{
|
||||||
@ -80,8 +81,9 @@ class TwoFactorCodeValidator implements ValidatorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
|
* @param mixed $codeDurationTime
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUnsuccessLoginMessage($codeDurationTime)
|
public function getUnsuccessLoginMessage($codeDurationTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,11 +13,10 @@ namespace Da\User\Validator;
|
|||||||
|
|
||||||
use Da\TwoFA\Exception\InvalidSecretKeyException;
|
use Da\TwoFA\Exception\InvalidSecretKeyException;
|
||||||
use Da\User\Model\User;
|
use Da\User\Model\User;
|
||||||
|
use Da\User\Service\TwoFactorEmailCodeGeneratorService;
|
||||||
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
|
||||||
use Da\User\Service\TwoFactorEmailCodeGeneratorService;
|
|
||||||
|
|
||||||
|
|
||||||
class TwoFactorEmailValidator extends TwoFactorCodeValidator
|
class TwoFactorEmailValidator extends TwoFactorCodeValidator
|
||||||
{
|
{
|
||||||
@ -50,8 +49,9 @@ class TwoFactorEmailValidator extends TwoFactorCodeValidator
|
|||||||
*/
|
*/
|
||||||
public function validate()
|
public function validate()
|
||||||
{
|
{
|
||||||
if(is_null($this->code) || $this->code == '' )
|
if (is_null($this->code) || $this->code == '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$emailCodeTime = new \DateTime(Yii::$app->session->get("email_code_time"));
|
$emailCodeTime = new \DateTime(Yii::$app->session->get("email_code_time"));
|
||||||
$currentTime = new \DateTime('now');
|
$currentTime = new \DateTime('now');
|
||||||
$interval = $currentTime->getTimestamp() - $emailCodeTime->getTimestamp();
|
$interval = $currentTime->getTimestamp() - $emailCodeTime->getTimestamp();
|
||||||
@ -86,8 +86,9 @@ class TwoFactorEmailValidator extends TwoFactorCodeValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
|
* @param mixed $codeDurationTime
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUnsuccessMessage($codeDurationTime)
|
public function getUnsuccessMessage($codeDurationTime)
|
||||||
{
|
{
|
||||||
@ -95,8 +96,9 @@ class TwoFactorEmailValidator extends TwoFactorCodeValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
|
* @param mixed $codeDurationTime
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUnsuccessLoginMessage($codeDurationTime)
|
public function getUnsuccessLoginMessage($codeDurationTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,11 +13,10 @@ namespace Da\User\Validator;
|
|||||||
|
|
||||||
use Da\TwoFA\Exception\InvalidSecretKeyException;
|
use Da\TwoFA\Exception\InvalidSecretKeyException;
|
||||||
use Da\User\Model\User;
|
use Da\User\Model\User;
|
||||||
|
use Da\User\Service\TwoFactorSmsCodeGeneratorService;
|
||||||
|
use Da\User\Traits\ContainerAwareTrait;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\helpers\ArrayHelper;
|
use yii\helpers\ArrayHelper;
|
||||||
use Da\User\Traits\ContainerAwareTrait;
|
|
||||||
use Da\User\Service\TwoFactorSmsCodeGeneratorService;
|
|
||||||
|
|
||||||
|
|
||||||
class TwoFactorTextMessageValidator extends TwoFactorCodeValidator
|
class TwoFactorTextMessageValidator extends TwoFactorCodeValidator
|
||||||
{
|
{
|
||||||
@ -51,8 +50,9 @@ class TwoFactorTextMessageValidator extends TwoFactorCodeValidator
|
|||||||
*/
|
*/
|
||||||
public function validate()
|
public function validate()
|
||||||
{
|
{
|
||||||
if(is_null($this->code) || $this->code == '' )
|
if (is_null($this->code) || $this->code == '') {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$smsCodeTime = new \DateTime(Yii::$app->session->get("sms_code_time"));
|
$smsCodeTime = new \DateTime(Yii::$app->session->get("sms_code_time"));
|
||||||
$currentTime = new \DateTime('now');
|
$currentTime = new \DateTime('now');
|
||||||
$interval = $currentTime->getTimestamp() - $smsCodeTime->getTimestamp();
|
$interval = $currentTime->getTimestamp() - $smsCodeTime->getTimestamp();
|
||||||
@ -77,8 +77,9 @@ class TwoFactorTextMessageValidator extends TwoFactorCodeValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
|
* @param mixed $codeDurationTime
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUnsuccessMessage($codeDurationTime)
|
public function getUnsuccessMessage($codeDurationTime)
|
||||||
{
|
{
|
||||||
@ -86,8 +87,9 @@ class TwoFactorTextMessageValidator extends TwoFactorCodeValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
|
||||||
*
|
*
|
||||||
|
* @param mixed $codeDurationTime
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUnsuccessLoginMessage($codeDurationTime)
|
public function getUnsuccessLoginMessage($codeDurationTime)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -69,6 +69,7 @@ class SessionStatusWidget extends Widget
|
|||||||
* Returns available auth items to be attached to the user.
|
* Returns available auth items to be attached to the user.
|
||||||
*
|
*
|
||||||
* @param int|null type of auth items or null to return all
|
* @param int|null type of auth items or null to return all
|
||||||
|
* @param null|mixed $type
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user