From f4a4ed8b4990910dd7d52495c7783f7990007f11 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 --- src/Forum/Actions/AuthenticatorTrait.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Forum/Actions/AuthenticatorTrait.php b/src/Forum/Actions/AuthenticatorTrait.php index 014598fbc..074bb0ac1 100644 --- a/src/Forum/Actions/AuthenticatorTrait.php +++ b/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); }