fixed issue: user login events not triggered on ajax requests
This commit is contained in:
@ -125,7 +125,14 @@ class SecurityController extends Controller
|
|||||||
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
|
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
|
||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
return ActiveForm::validate($form);
|
$this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event);
|
||||||
|
$errors = ActiveForm::validate($form);
|
||||||
|
if(empty($errors)) {
|
||||||
|
$this->trigger(FormEvent::EVENT_AFTER_LOGIN, $event);
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
$this->trigger(FormEvent::EVENT_FAILED_LOGIN, $event);
|
||||||
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($form->load(Yii::$app->request->post())) {
|
if ($form->load(Yii::$app->request->post())) {
|
||||||
@ -150,7 +157,7 @@ class SecurityController extends Controller
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->trigger(FormEvent::EVENT_FAILED_LOGIN, $event);
|
$this->trigger(FormEvent::EVENT_FAILED_LOGIN, $event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user