Files
streamline/scripts/local-sso.ts
T
2026-11-16 17:26:44 -08:00

16 lines
964 B
TypeScript

/** Used ONLY by vite.local.config.ts (serve-only). Never bundled for production. */
export interface SsoUser { email: string; name: string; avatarUrl: string }
const user: SsoUser = { email: "streamline-local@bytedance.com", name: "本地测试管理员", avatarUrl: "" };
let current: SsoUser | null = user;
export const getCurrentSsoUser = () => current;
export const getCurrentSsoEmail = () => current?.email || null;
export const setCurrentSsoUser = (value: SsoUser | null) => { current = value; };
export const getSsoSessionToken = () => import.meta.env.VITE_LOCAL_SESSION_TOKEN as string;
export const ssoAuthHeaders = () => ({ "x-tt-session-v2": getSsoSessionToken() });
export const fetchUserInfo = async () => user;
export const isLogin = async () => true;
export const loadSsoSdk = async () => true;
export const ssoAvailable = () => true;
export const logout = () => { current = null; };
export const login = () => { location.reload(); return true; };