Merge pull request #446 from TonisOrmisson/use-login-ajax-events

fixed issue: user login events not triggered on ajax requests
This commit is contained in:
Lorenzo Milesi
2022-02-16 17:23:10 +01:00
committed by GitHub
2 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,7 @@
# CHANGELOG
## work in progress
- Fix user login events not triggered on ajax requests (TonisOrmisson)
- Enh: Added minimum requirements when a new password is automatically generated (MatteoF96)
- Fix #380: Avoid rewriting AccessRule::matchRole (maxxer)
- Fix #378: Add module attribute 'disableIpLogging' (jkmssoft)

View File

@ -125,7 +125,14 @@ class SecurityController extends Controller
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())) {
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())) {