(READ ONLY) Margin is an open annotation layer for the internet. Powered by the AT Protocol.
Something went wrong. Try again.
1234567891011121314151617181920212223242526import { atom } from "nanostores";import { loadPreferences } from "./preferences";import type { UserProfile } from "../types";import { analytics } from "../lib/analytics";
export const $user = atom<UserProfile | null>(null);
$user.subscribe((user) => { if (user) { loadPreferences(); analytics.identify(user.did, { handle: user.handle, displayName: user.displayName, }); }});
export function logout() { analytics.capture("user_logged_out"); analytics.reset(); $user.set(null); fetch("/auth/logout", { method: "POST" }).finally(() => { window.location.href = "/"; });}