From af1ac1ef42865e2284c0d19e4c2b0d7f3c202796 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 17 Sep 2015 12:57:22 +0930 Subject: [PATCH] Extend social login access token expiry --- framework/core/src/Forum/Actions/AuthenticatorTrait.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/framework/core/src/Forum/Actions/AuthenticatorTrait.php b/framework/core/src/Forum/Actions/AuthenticatorTrait.php index 014598fbc..074bb0ac1 100644 --- a/framework/core/src/Forum/Actions/AuthenticatorTrait.php +++ b/framework/core/src/Forum/Actions/AuthenticatorTrait.php @@ -14,6 +14,7 @@ use Flarum\Core\Users\User; use Zend\Diactoros\Response\HtmlResponse; use Flarum\Api\Commands\GenerateAccessToken; use Flarum\Core\Users\AuthToken; +use DateTime; trait AuthenticatorTrait { @@ -71,6 +72,11 @@ window.close(); $response = new HtmlResponse($content); if (isset($accessToken)) { + // Extend the token's expiry to 2 weeks so that we can set a + // remember cookie + $accessToken::unguard(); + $accessToken->update(['expires_at' => new DateTime('+2 weeks')]); + $response = $this->withRememberCookie($response, $accessToken->id); }