Skip to content

Commit 9203e49

Browse files
committed
Allow casting from String -> Double when checking timestamps
Not all server-side JWT packages drop the quotes around returned values, which causes a decoding error to occur because `as? NSTimeInterval` will fail on strings.
1 parent 751bd84 commit 9203e49

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

JWT/Claims.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func validateIssuer(payload:Payload, issuer:String?) -> InvalidToken? {
4040
}
4141

4242
func validateDate(payload:Payload, key:String, comparison:NSComparisonResult, failure:InvalidToken, decodeError:String) -> InvalidToken? {
43-
if let timestamp = payload[key] as? NSTimeInterval {
43+
if let timestamp = payload[key] as? NSTimeInterval ?? payload[key]?.doubleValue as NSTimeInterval? {
4444
let date = NSDate(timeIntervalSince1970: timestamp)
4545
if date.compare(NSDate()) == comparison {
4646
return failure

0 commit comments

Comments
 (0)