Only update the last_login_at attribute in case of a successful login

This commit is contained in:
pappfer
2017-07-31 16:36:58 +02:00
parent dfe6a3b0ef
commit 4762e47405
2 changed files with 2 additions and 1 deletions

View File

@ -124,6 +124,8 @@ class SecurityController extends Controller
if ($form->load(Yii::$app->request->post())) {
$this->trigger(FormEvent::EVENT_BEFORE_LOGIN, $event);
if ($form->login()) {
Yii::$app->getUser()->identity->updateAttributes(['last_login_at' => time()]);
$this->trigger(FormEvent::EVENT_AFTER_LOGIN, $event);
return $this->goBack();

View File

@ -117,7 +117,6 @@ class LoginForm extends Model
{
if ($this->validate()) {
$duration = $this->rememberMe ? $this->module->rememberLoginLifespan : 0;
$this->user->updateAttributes(['last_login_at' => time()]);
return Yii::$app->getUser()->login($this->user, $duration);
}