File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -91,13 +91,18 @@ public function add(Payload $payload)
91
91
*/
92
92
protected function getMinutesUntilExpired (Payload $ payload )
93
93
{
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 );
96
103
97
- // get the latter of the two expiration dates and find
98
- // the number of minutes until the expiration date,
99
104
// plus 1 minute to avoid overlap
100
- return $ exp -> max ( $ iat -> addMinutes ( $ this -> refreshTTL ))-> addMinute ()-> diffInRealMinutes () ;
105
+ return $ minutesUntilExpired + 1 ;
101
106
}
102
107
103
108
/**
You can’t perform that action at this time.
0 commit comments