Angular2-jwt: Always returns isExpired as true. Had to rollback to angular2-jwt to make it work properly.

Created on 23 Mar 2018  ·  6Comments  ·  Source: auth0/angular2-jwt

` isLoggedIn(){
const jwtHelper = new JwtHelperService();
let token = localStorage.getItem('token');

if (!token) {

  return false;

} else {

  let expDate = jwtHelper.getTokenExpirationDate(token);
  let isExpired = jwtHelper.isTokenExpired(token);

  console.log('Expiration Date',expDate);
  console.log('isExpired',isExpired);

  return !isExpired;
}

}`

stale

Most helpful comment

This is the commit that changed the behavior quite explicitly:

https://github.com/auth0/angular2-jwt/commit/ce750feddf7073aedc73f024b7fe962471eabcf7#diff-b827188f6870a4e92c47864505a1fd95

The code change appears to be inconsistent with the RFC, in that the exp claim is optional (https://tools.ietf.org/html/rfc7519#section-4.1.4).

Can we get this change reverted?

All 6 comments

Is this still happening?

It's happening for me with v1.2.0 when the token is missing an expiration value

This is the commit that changed the behavior quite explicitly:

https://github.com/auth0/angular2-jwt/commit/ce750feddf7073aedc73f024b7fe962471eabcf7#diff-b827188f6870a4e92c47864505a1fd95

The code change appears to be inconsistent with the RFC, in that the exp claim is optional (https://tools.ietf.org/html/rfc7519#section-4.1.4).

Can we get this change reverted?

I'm seeing the same behavior as @srudolph-credera on v.2.0.0.

If a JWT doesn't have an exp then isTokenExpired always returns true.

I resolved that issue setting expiresIn property in my backend

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️

Was this page helpful?
0 / 5 - 0 ratings