Skip to content

Commit

Permalink
Merge pull request #446 from TonisOrmisson/use-login-ajax-events
Browse files Browse the repository at this point in the history
fixed issue: user login events not triggered on ajax requests
  • Loading branch information
maxxer committed Feb 16, 2022
2 parents a99f05a + 60feeaf commit c32a2ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
11 changes: 9 additions & 2 deletions src/User/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,14 @@ public function actionLogin()
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())) {
Expand All @@ -150,7 +157,7 @@ public function actionLogin()
}
else
{
$this->trigger(FormEvent::EVENT_FAILED_LOGIN, $event);
$this->trigger(FormEvent::EVENT_FAILED_LOGIN, $event);
}
}

Expand Down

0 comments on commit c32a2ca

Please sign in to comment.