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, '/');
|
setcookie('auth', TextHelper::encrypt($token), time() + 365 * 24 * 3600, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user->setLastLoginTime(time());
|
||||||
|
|
||||||
self::setCurrentUser($user);
|
self::setCurrentUser($user);
|
||||||
|
|
||||||
$user->setLastLoginTime(time());
|
|
||||||
UserModel::save($user);
|
UserModel::save($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ class UserController extends AbstractController
|
||||||
$user = Api::run(
|
$user = Api::run(
|
||||||
new EditUserSettingsJob(),
|
new EditUserSettingsJob(),
|
||||||
[
|
[
|
||||||
JobArgs::ARG_USER_ENTITY => Auth::getCurrentUser(),
|
JobArgs::ARG_USER_ENTITY => $user,
|
||||||
JobArgs::ARG_NEW_SETTINGS => [UserSettings::SETTING_SAFETY => $desiredSafety],
|
JobArgs::ARG_NEW_SETTINGS => [UserSettings::SETTING_SAFETY => $desiredSafety],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ class AuthTest extends AbstractTest
|
||||||
|
|
||||||
$this->assert->isTrue(Auth::isLoggedIn());
|
$this->assert->isTrue(Auth::isLoggedIn());
|
||||||
|
|
||||||
$user = UserModel::getByName($user->getName());
|
$this->assertValidUser(UserModel::getByName($user->getName()));
|
||||||
$this->assert->areEqual(time(), $user->getLastLoginTime());
|
$this->assertValidUser(Auth::getCurrentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAutoLogin()
|
public function testAutoLogin()
|
||||||
|
@ -28,6 +28,8 @@ class AuthTest extends AbstractTest
|
||||||
$user = $this->prepareValidUser();
|
$user = $this->prepareValidUser();
|
||||||
UserModel::save($user);
|
UserModel::save($user);
|
||||||
|
|
||||||
|
$this->assert->isNull($user->getLastLoginTime());
|
||||||
|
|
||||||
$token = base64_encode('existing') . '|' . base64_encode('bleee');
|
$token = base64_encode('existing') . '|' . base64_encode('bleee');
|
||||||
$_COOKIE['auth'] = TextHelper::encrypt($token);
|
$_COOKIE['auth'] = TextHelper::encrypt($token);
|
||||||
|
|
||||||
|
@ -38,8 +40,8 @@ class AuthTest extends AbstractTest
|
||||||
|
|
||||||
$this->assert->isTrue(Auth::isLoggedIn());
|
$this->assert->isTrue(Auth::isLoggedIn());
|
||||||
|
|
||||||
$user = UserModel::getByName($user->getName());
|
$this->assertValidUser(UserModel::getByName($user->getName()));
|
||||||
$this->assert->areEqual(time(), $user->getLastLoginTime());
|
$this->assertValidUser(Auth::getCurrentUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAutoLoginInvalidToken()
|
public function testAutoLoginInvalidToken()
|
||||||
|
@ -247,4 +249,10 @@ class AuthTest extends AbstractTest
|
||||||
$user->setPassword('bleee');
|
$user->setPassword('bleee');
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function assertValidUser($user)
|
||||||
|
{
|
||||||
|
$this->assert->areEqual('existing', $user->getName());
|
||||||
|
$this->assert->areEqual(time(), $user->getLastLoginTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue