Added token verification to find out whether the token is expired or not and fixed the token expiration bug.
//Token expiry verification
var tokenisExpired = false;
var tokendata = localStorage.getItem('AUTH_TOKEN');
if (tokendata) {
console.log('Tokendata==>>', tokendata);
var decodedToken = jwt.decode(tokendata, { complete: true });
console.log('decodedTokendata==>>', decodedToken.payload.exp * 1000);
var dateNow = new Date();
console.log('datenow.time===>', dateNow.getTime());
//multiplying the token exp with 1000 to make the no.of digits of exp to 13 so that it can be compared with the dateNow.getTime()
if (decodedToken.payload.exp * 1000 < dateNow.getTime())
tokenisExpired = true;
console.log('isTokenExpired=>>', tokenisExpired);
}
Now if the token is expired it is removed from the local storage.
Added token verification to find out whether the token is expired or not and fixed the token expiration bug.
Now if the token is expired it is removed from the local storage.