in web/index.ts [194:222]
public async checkExpiration(): Promise<boolean> {
// Refresh the token if it is expired
const expCookie = Cookies.get('jwt.expires');
let expires: Date;
if (expCookie) {
expires = new Date(expCookie);
if (expires < new Date()) {
const refresh = Cookies.get('jwt.refresh');
console.log('Refreshing jwt token: ' + refresh);
// Refresh the token
const resp = await axios.default({
url: this.apiUrl + '/' + `decode-verify-jwt?refresh=${refresh}`,
method: 'get'
});
console.log('decode-verify-jwt refresh response: ' +
JSON.stringify(resp, null, 0));
this.setAuthCookies(resp.data);
}
return true;
} else {
this.logout();
return false;
}
}