Skip to content

Commit 280bf6b

Browse files
committed
Checking the token expiry time
Checking if our token has expired.
1 parent 53669d6 commit 280bf6b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Authentication/JWT.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public static function decode($jwt, $key = null, $verify = true)
6161
if ($sig != JWT::sign("$headb64.$bodyb64", $key, $header->alg)) {
6262
throw new UnexpectedValueException('Signature verification failed');
6363
}
64+
// Check token expiry time if defined.
65+
if (isset($payload->exp) && time() >= $payload->exp){
66+
throw new UnexpectedValueException('Expired Token');
67+
}
68+
6469
}
6570
return $payload;
6671
}

0 commit comments

Comments
 (0)