From c50c368d2f4ecd495ea15441ee863e238cbd5f47 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 18 May 2014 20:52:35 +0200 Subject: [PATCH] Fixed last login time --- src/Auth.php | 3 +++ src/Models/Entities/UserEntity.php | 4 ++-- tests/Tests/MiscTests/AuthTest.php | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Auth.php b/src/Auth.php index 2e99a90a..be352350 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -37,6 +37,9 @@ class Auth } self::setCurrentUser($user); + + $user->setLastLoginTime(time()); + UserModel::save($user); } public static function tryAutoLogin() diff --git a/src/Models/Entities/UserEntity.php b/src/Models/Entities/UserEntity.php index 6657a95d..b84694b2 100644 --- a/src/Models/Entities/UserEntity.php +++ b/src/Models/Entities/UserEntity.php @@ -35,8 +35,8 @@ final class UserEntity extends AbstractEntity implements IValidatable, ISerializ $this->staffConfirmed = $row['staff_confirmed']; $this->emailUnconfirmed = $row['email_unconfirmed']; $this->emailConfirmed = $row['email_confirmed']; - $this->joinDate = $row['join_date']; - $this->lastLoginDate = $row['last_login_date']; + $this->joinDate = TextHelper::toIntegerOrNull($row['join_date']); + $this->lastLoginDate = TextHelper::toIntegerOrNull($row['last_login_date']); $this->banned = $row['banned']; $this->setAccessRank(new AccessRank($row['access_rank'])); $this->settings = new UserSettings($row['settings']); diff --git a/tests/Tests/MiscTests/AuthTest.php b/tests/Tests/MiscTests/AuthTest.php index 9af1c95f..2a4e7ff2 100644 --- a/tests/Tests/MiscTests/AuthTest.php +++ b/tests/Tests/MiscTests/AuthTest.php @@ -15,6 +15,9 @@ class AuthTest extends AbstractTest }); $this->assert->isTrue(Auth::isLoggedIn()); + + $user = UserModel::getByName($user->getName()); + $this->assert->areEqual(time(), $user->getLastLoginTime()); } public function testLoginViaEmail()