Close #55 add google captcha mechanism

This commit is contained in:
Antonio Ramirez
2017-10-15 22:11:35 +02:00
parent 299ab1e4ea
commit 20400cf90d
40 changed files with 660 additions and 361 deletions

View File

@ -156,10 +156,9 @@ class RecoveryController extends Controller
if ($form->load(Yii::$app->getRequest()->post())) {
if ($this->make(ResetPasswordService::class, [$form->password, $token->user])->run()) {
$this->trigger(ResetPasswordEvent::EVENT_AFTER_RESET, $event);
Yii::$app->session->setFlash('success',Yii::t('usuario', 'Password has been changed'));
Yii::$app->session->setFlash('success', Yii::t('usuario', 'Password has been changed'));
return $this->render(
'/shared/message',

View File

@ -37,10 +37,10 @@ class SecurityController extends Controller
/**
* SecurityController constructor.
*
* @param string $id
* @param Module $module
* @param string $id
* @param Module $module
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
* @param array $config
* @param array $config
*/
public function __construct(
$id,
@ -117,14 +117,12 @@ class SecurityController extends Controller
$event = $this->make(FormEvent::class, [$form]);
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($form);
}
if ($form->load(Yii::$app->request->post())) {
if ($this->module->enableTwoFactorAuthentication && $form->validate()) {
if ($form->getUser()->auth_tf_enabled) {
Yii::$app->session->set('credentials', ['login' => $form->login, 'pwd' => $form->password]);
@ -173,18 +171,15 @@ class SecurityController extends Controller
$event = $this->make(FormEvent::class, [$form]);
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($form);
}
if ($form->load(Yii::$app->request->post())) {
$this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event);
if ($form->login()) {
Yii::$app->session->set('credentials', null);
$form->getUser()->updateAttributes(['last_login_at' => time()]);
@ -202,7 +197,6 @@ class SecurityController extends Controller
'module' => $this->module,
]
);
}
public function actionLogout()

View File

@ -52,12 +52,12 @@ class SettingsController extends Controller
/**
* SettingsController constructor.
*
* @param string $id
* @param Module $module
* @param ProfileQuery $profileQuery
* @param UserQuery $userQuery
* @param string $id
* @param Module $module
* @param ProfileQuery $profileQuery
* @param UserQuery $userQuery
* @param SocialNetworkAccountQuery $socialNetworkAccountQuery
* @param array $config
* @param array $config
*/
public function __construct(
$id,
@ -294,8 +294,7 @@ class SettingsController extends Controller
throw new NotFoundHttpException();
}
if($user->updateAttributes(['auth_tf_enabled' => '0']))
{
if ($user->updateAttributes(['auth_tf_enabled' => '0'])) {
Yii::$app
->getSession()
->setFlash('success', Yii::t('usuario', 'Two-factor authorization has been disabled.'));