2021-01-17 12:54:49 -08:00
|
|
|
import Cookies from 'js-cookie';
|
|
|
|
import { makeVar } from '@apollo/client';
|
2021-03-11 13:38:35 -08:00
|
|
|
import { GlobalCfg } from '../../conf';
|
2021-05-11 15:41:42 -07:00
|
|
|
import analytics from '../analytics';
|
2021-01-17 12:54:49 -08:00
|
|
|
|
|
|
|
export const checkAuthStatus = (): boolean => {
|
2021-05-11 15:41:42 -07:00
|
|
|
const isAuthenticated = !!Cookies.get(GlobalCfg.CLIENT_AUTH_COOKIE);
|
|
|
|
if (isAuthenticated) {
|
|
|
|
analytics.identify(Cookies.get(GlobalCfg.CLIENT_AUTH_COOKIE) as string);
|
|
|
|
}
|
|
|
|
return isAuthenticated;
|
2021-01-17 12:54:49 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
export const isLoggedInVar = makeVar(checkAuthStatus());
|