diff --git a/framework/core/src/Forum/Controller/LogInController.php b/framework/core/src/Forum/Controller/LogInController.php index 3a864c81b..eebeb03b3 100644 --- a/framework/core/src/Forum/Controller/LogInController.php +++ b/framework/core/src/Forum/Controller/LogInController.php @@ -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; diff --git a/framework/core/src/Http/Rememberer.php b/framework/core/src/Http/Rememberer.php index 254bbf99f..4e1973475 100644 --- a/framework/core/src/Http/Rememberer.php +++ b/framework/core/src/Http/Rememberer.php @@ -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)