예제 소스
SGF 기보로 학습하는 바둑 LLM 인공지능 · 파일 169개
auth.ts
const AUTH_KEY = "mariago_session";
export type Session = {
email: string;
nickname: string;
};
export function saveSession(s: Session): void {
if (typeof window === "undefined") return;
localStorage.setItem(AUTH_KEY, JSON.stringify(s));
}
export function loadSession(): Session | null {
if (typeof window === "undefined") return null;
try {
const raw = localStorage.getItem(AUTH_KEY);
if (!raw) return null;
return JSON.parse(raw) as Session;
} catch {
return null;
}
}
export function clearSession(): void {
if (typeof window === "undefined") return;
localStorage.removeItem(AUTH_KEY);
}