diff --git a/EventListener/AttachRefreshTokenOnSuccessListener.php b/EventListener/AttachRefreshTokenOnSuccessListener.php index 57639acb..1e2c1866 100644 --- a/EventListener/AttachRefreshTokenOnSuccessListener.php +++ b/EventListener/AttachRefreshTokenOnSuccessListener.php @@ -131,16 +131,21 @@ public function attachRefreshToken(AuthenticationSuccessEvent $event): void // Set or create the refreshTokenString if ($refreshTokenString) { $data[$this->tokenParameterName] = $refreshTokenString; + + if ($this->returnExpiration) { + $refreshToken = $this->refreshTokenManager->get($refreshTokenString); + $data[$this->returnExpirationParameterName] = ($refreshToken) ? $refreshToken->getValid()->getTimestamp() : 0; + } } else { $refreshToken = $this->refreshTokenGenerator->createForUserWithTtl($user, $this->ttl); $this->refreshTokenManager->save($refreshToken); $refreshTokenString = $refreshToken->getRefreshToken(); $data[$this->tokenParameterName] = $refreshTokenString; - } - if ($this->returnExpiration) { - $data[$this->returnExpirationParameterName] = time() + $this->ttl; + if ($this->returnExpiration) { + $data[$this->returnExpirationParameterName] = $refreshToken->getValid()->getTimestamp(); + } } // Add a response cookie if enabled