-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix expiry date extraction of a credential
- Loading branch information
Showing
2 changed files
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
// CheckExpired.js | ||
export function CheckExpired(expiry_date) { | ||
if (!expiry_date) { | ||
export function CheckExpired(data) { | ||
|
||
if (!data.exp || typeof data.exp != 'number') { | ||
return false; | ||
} | ||
|
||
const parsedExpiryDate = typeof expiry_date == 'string' ? expiry_date : new Date(expiry_date * 1000).toISOString(); | ||
const today = new Date(); | ||
const expirationDate = new Date(parsedExpiryDate); | ||
return expirationDate < today; | ||
const parsedExpiryDate = new Date(data.exp * 1000); | ||
console.log("Parsed expiry date = ", parsedExpiryDate) | ||
return parsedExpiryDate < new Date(); | ||
}; |