Skip to content

Commit 90289d5

Browse files
committed
Do not update user if it is not logged
Closes #967 #968
1 parent a025d44 commit 90289d5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

models/LoginForm.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,13 @@ public function validatePassword($attribute, $params)
142142
public function login()
143143
{
144144
if ($this->validate() && $this->user) {
145-
$this->user->updateAttributes(['last_login_at' => time()]);
146-
return Yii::$app->getUser()->login($this->user, $this->rememberMe ? $this->module->rememberFor : 0);
145+
$isLogged = Yii::$app->getUser()->login($this->user, $this->rememberMe ? $this->module->rememberFor : 0);
146+
147+
if ($isLogged) {
148+
$this->user->updateAttributes(['last_login_at' => time()]);
149+
}
150+
151+
return $isLogged;
147152
}
148153

149154
return false;

0 commit comments

Comments
 (0)