return false from isTokenValid only if api resonse is 401

This commit is contained in:
Abhinav 2022-05-30 21:23:03 +05:30
parent 49ce07ffc9
commit f9b143c67a

View file

@ -18,6 +18,7 @@ import {
UserDetails,
} from 'types/user';
import { getFamilyData, isPartOfFamily } from 'utils/billing';
import { ServerErrorCodes } from 'utils/error';
const ENDPOINT = getEndpoint();
@ -161,7 +162,12 @@ export const isTokenValid = async () => {
}
return true;
} catch (e) {
return false;
logError(e, 'session-validity api call failed');
if (e.status?.toString() === ServerErrorCodes.SESSION_EXPIRED) {
return false;
} else {
return true;
}
}
};