Extend access token lifetime when remembering a login

This commit is contained in:
Toby Zerner 2016-01-02 15:08:28 +10:30
parent d242894938
commit 1fe6ff1b6f
2 changed files with 7 additions and 6 deletions

View File

@ -79,7 +79,7 @@ class LogInController implements ControllerInterface
event(new UserLoggedIn($this->users->findOrFail($data->userId), $token));
$response = $this->rememberer->remember($response, $token->id);
$response = $this->rememberer->remember($response, $token);
}
return $response;

View File

@ -18,12 +18,15 @@ class Rememberer
{
protected $cookieName = 'flarum_remember';
public function remember(ResponseInterface $response, $token)
public function remember(ResponseInterface $response, AccessToken $token)
{
$token->lifetime = 60 * 60 * 24 * 14;
$token->save();
return FigResponseCookies::set(
$response,
$this->createCookie()
->withValue($token)
->withValue($token->id)
->withMaxAge(14 * 24 * 60 * 60)
);
}
@ -31,10 +34,8 @@ class Rememberer
public function rememberUser(ResponseInterface $response, $userId)
{
$token = AccessToken::generate($userId);
$token->lifetime = 60 * 60 * 24 * 14;
$token->save();
return $this->remember($response, $token->id);
return $this->remember($response, $token);
}
public function forget(ResponseInterface $response)