Skip to content

Commit 2d31d3e

Browse files
committed
Fix compatibility with Carbon 3.x
1 parent 51620eb commit 2d31d3e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/Blacklist.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,18 @@ public function add(Payload $payload)
9191
*/
9292
protected function getMinutesUntilExpired(Payload $payload)
9393
{
94-
$exp = Utils::timestamp($payload['exp']);
95-
$iat = Utils::timestamp($payload['iat']);
94+
$now = time();
95+
$exp = Utils::timestamp($payload['exp'])->getTimestamp();
96+
$iat = Utils::timestamp($payload['iat'])->getTimestamp();
97+
98+
// get the latter of the two expiration timestamps
99+
$latterTs = max([$exp, $iat + 60 * $this->refreshTTL]);
100+
101+
// find the number of minutes until the expiration timestamp
102+
$minutesUntilExpired = (int)(($latterTs - $now) / 60);
96103

97-
// get the latter of the two expiration dates and find
98-
// the number of minutes until the expiration date,
99104
// plus 1 minute to avoid overlap
100-
return $exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInRealMinutes();
105+
return $minutesUntilExpired + 1;
101106
}
102107

103108
/**

0 commit comments

Comments
 (0)