mirror of
https://github.com/flarum/framework.git
synced 2024-12-04 08:13:39 +08:00
Extend access token lifetime when remembering a login
This commit is contained in:
parent
d242894938
commit
1fe6ff1b6f
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user