added isTokenActive

This commit is contained in:
Abhinav-grd 2021-03-29 11:52:15 +05:30
parent 2c29ed6606
commit 20a5bea858

View file

@ -5,6 +5,7 @@ import { clearKeys } from 'utils/storage/sessionStorage';
import router from 'next/router';
import { clearData } from 'utils/storage/localStorage';
import localForage from 'utils/storage/localForage';
import { getToken } from 'utils/common/key';
const ENDPOINT = getEndpoint();
@ -52,3 +53,16 @@ export const logoutUser = async () => {
export const clearFiles = async () => {
await localForage.clear();
};
export const isTokenValid = async () => {
try {
await HTTPService.get(`${ENDPOINT}/users/heartbeat`, null, {
'X-Auth-Token': getToken(),
});
console.log('gg');
return true;
} catch (e) {
console.log('bg');
return false;
}
};