Skip to content

Commit

Permalink
Update last_login_at and last_login_ip on login via auth action
Browse files Browse the repository at this point in the history
  • Loading branch information
eluhr committed Mar 7, 2024
1 parent 780feea commit 5d8dadf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## dev

- Fix: Update last_login_at and last_login_ip on social networt authenticate (e.luhr)
- Enh: Keycloak auth client (e.luhr)
- Fix: Social Network Auth (eluhr)
- Enh #532: /user/registration/register now shows form validation errors
Expand Down
11 changes: 8 additions & 3 deletions src/User/Service/SocialNetworkAuthenticateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ public function run()
Yii::$app->session->setFlash('danger', Yii::t('usuario', 'Your account has been blocked.'));
$this->authAction->setSuccessUrl(Url::to(['/user/security/login']));
} else {
Yii::$app->user->login($account->user, $this->controller->module->rememberLoginLifespan);
$this->authAction->setSuccessUrl(Yii::$app->getUser()->getReturnUrl());
$result = true;
$result = Yii::$app->user->login($account->user, $this->controller->module->rememberLoginLifespan);
if ($result) {
$account->user->updateAttributes([
'last_login_at' => time(),
'last_login_ip' => $this->controller->module->disableIpLogging ? '127.0.0.1' : Yii::$app->request->getUserIP(),
]);
$this->authAction->setSuccessUrl(Yii::$app->getUser()->getReturnUrl());
}
}
} else {
$this->authAction->setSuccessUrl($account->getConnectionUrl());
Expand Down

0 comments on commit 5d8dadf

Please sign in to comment.