-
Hello Good day specs
Am trying to verify expiry date but since I migrated from https://github.com/dgrijalva/jwt-go to https://github.com/golang-jwt/jwt I can't compare the expiry date with the current datetime. Here is my code sample
Please help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Unfortunately Go does not allow to overload operators, so you cannot use
Note: in your example, the first |
Beta Was this translation helpful? Give feedback.
Unfortunately Go does not allow to overload operators, so you cannot use
>
to compare thejwt.NumericDate
with seconds or another time. You can however use the functionVerifyExpiresAt
which will abstract this for you:Note: in your example, the first
if token.Valid
should probably beif !token.Valid
because if the token is valid, it can never be expired (in our current system, unless you have override this behaviour somehow).