Fix inviter id setting (#17)

This commit is contained in:
AceDataCloud committed 2024-01-03 02:22:40 +08:00
1 parent fa0250beca
commit 140a585316
5 files changed
+20 -40

No files matched your search

-31
View File
@@ -1,31 +0,0 @@
import { removeCookie, setCookie as baseSetCookie } from 'typescript-cookie';
import { CookieAttributes } from 'typescript-cookie/dist/types';
export const getDomain = () => {
const host = window.location.host;
// process test env and prod env, for example:
// auth.zhishuyun.com -> .zhishuyun.com
// auth.test.zhishuyun.com -> .zhishuyun.com
const domain = host.replace(/^\S+?\.(test\.|local\.)?/, '.');
return domain;
};
export const getPath = () => {
return '/';
};
export const setCookie = (key: string, value: string, attributes: CookieAttributes) => {
baseSetCookie(key, value, {
domain: attributes?.domain || getDomain(),
path: attributes?.path || getPath(),
expires: attributes?.expires,
sameSite: attributes?.sameSite,
secure: attributes?.secure
});
};
export const resetCookies = () => {
// remove tokens from cookies
removeCookie('ACCESS_TOKEN', { domain: getDomain(), path: getPath() });
removeCookie('REFRESH_TOKEN', { domain: getDomain(), path: getPath() });
};
-1
View File
@@ -1,4 +1,3 @@
export * from './baseUrl';
export * from './mode';
export * from './log';
export * from './cookies';