Only update the last_login_at attribute in case of a successful login
This commit is contained in:
@ -124,6 +124,8 @@ class SecurityController extends Controller
|
|||||||
if ($form->load(Yii::$app->request->post())) {
|
if ($form->load(Yii::$app->request->post())) {
|
||||||
$this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event);
|
$this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event);
|
||||||
if ($form->login()) {
|
if ($form->login()) {
|
||||||
|
Yii::$app->getUser()->identity->updateAttributes(['last_login_at' => time()]);
|
||||||
|
|
||||||
$this->trigger(FormEvent::EVENT_AFTER_LOGIN, $event);
|
$this->trigger(FormEvent::EVENT_AFTER_LOGIN, $event);
|
||||||
|
|
||||||
return $this->goBack();
|
return $this->goBack();
|
||||||
|
|||||||
@ -117,7 +117,6 @@ class LoginForm extends Model
|
|||||||
{
|
{
|
||||||
if ($this->validate()) {
|
if ($this->validate()) {
|
||||||
$duration = $this->rememberMe ? $this->module->rememberLoginLifespan : 0;
|
$duration = $this->rememberMe ? $this->module->rememberLoginLifespan : 0;
|
||||||
$this->user->updateAttributes(['last_login_at' => time()]);
|
|
||||||
|
|
||||||
return Yii::$app->getUser()->login($this->user, $duration);
|
return Yii::$app->getUser()->login($this->user, $duration);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user