Fixed rare bug regarding last login time
This commit is contained in:
parent
0ebfaf991a
commit
e382dc7f7d
3 changed files with 15 additions and 6 deletions
|
@ -36,9 +36,10 @@ class Auth
|
|||
setcookie('auth', TextHelper::encrypt($token), time() + 365 * 24 * 3600, '/');
|
||||
}
|
||||
|
||||
$user->setLastLoginTime(time());
|
||||
|
||||
self::setCurrentUser($user);
|
||||
|
||||
$user->setLastLoginTime(time());
|
||||
UserModel::save($user);
|
||||
}
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ class UserController extends AbstractController
|
|||
$user = Api::run(
|
||||
new EditUserSettingsJob(),
|
||||
[
|
||||
JobArgs::ARG_USER_ENTITY => Auth::getCurrentUser(),
|
||||
JobArgs::ARG_USER_ENTITY => $user,
|
||||
JobArgs::ARG_NEW_SETTINGS => [UserSettings::SETTING_SAFETY => $desiredSafety],
|
||||
]);
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ class AuthTest extends AbstractTest
|
|||
|
||||
$this->assert->isTrue(Auth::isLoggedIn());
|
||||
|
||||
$user = UserModel::getByName($user->getName());
|
||||
$this->assert->areEqual(time(), $user->getLastLoginTime());
|
||||
$this->assertValidUser(UserModel::getByName($user->getName()));
|
||||
$this->assertValidUser(Auth::getCurrentUser());
|
||||
}
|
||||
|
||||
public function testAutoLogin()
|
||||
|
@ -28,6 +28,8 @@ class AuthTest extends AbstractTest
|
|||
$user = $this->prepareValidUser();
|
||||
UserModel::save($user);
|
||||
|
||||
$this->assert->isNull($user->getLastLoginTime());
|
||||
|
||||
$token = base64_encode('existing') . '|' . base64_encode('bleee');
|
||||
$_COOKIE['auth'] = TextHelper::encrypt($token);
|
||||
|
||||
|
@ -38,8 +40,8 @@ class AuthTest extends AbstractTest
|
|||
|
||||
$this->assert->isTrue(Auth::isLoggedIn());
|
||||
|
||||
$user = UserModel::getByName($user->getName());
|
||||
$this->assert->areEqual(time(), $user->getLastLoginTime());
|
||||
$this->assertValidUser(UserModel::getByName($user->getName()));
|
||||
$this->assertValidUser(Auth::getCurrentUser());
|
||||
}
|
||||
|
||||
public function testAutoLoginInvalidToken()
|
||||
|
@ -247,4 +249,10 @@ class AuthTest extends AbstractTest
|
|||
$user->setPassword('bleee');
|
||||
return $user;
|
||||
}
|
||||
|
||||
private function assertValidUser($user)
|
||||
{
|
||||
$this->assert->areEqual('existing', $user->getName());
|
||||
$this->assert->areEqual(time(), $user->getLastLoginTime());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue