diff --git a/CHANGELOG.md b/CHANGELOG.md index b02a88d..ff31b36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip - Change the minimum required version of guzzle from `^6.2` to `6.*` - Fixed the alias version in composer. -## v0.3.0 - 2017-09-15 +## v0.3.0 - 2017-09-14 ### Bug - Function that was calculating the timeout token if it was valid was wrong. diff --git a/src/Token/TimeoutToken.php b/src/Token/TimeoutToken.php index 34d1d71..72f2733 100644 --- a/src/Token/TimeoutToken.php +++ b/src/Token/TimeoutToken.php @@ -34,16 +34,15 @@ public function __construct($token, EncoderInterface $encoder = null, $offset = public function isValid() { $payload = $this->getPayload(); - if (isset($payload['exp'])) { $now = new \DateTime('now'); if (is_int($payload['exp'])) { - return ($now->getTimestamp() - $payload['exp'] - $this->offset) > 0; + return ($payload['exp'] - $this->offset - $now->getTimestamp()) > 0; } if (is_numeric($payload['exp'])) { - return ($now->format('U') - $payload['exp'] - $this->offset) > 0; + return ($payload['exp'] - $this->offset - $now->format('U')) > 0; } }