tianji/src/client/api/auth.ts
2023-10-20 23:12:42 +08:00

16 lines
357 B
TypeScript

const TOKEN_STORAGE_KEY = 'jsonwebtoken';
export function getJWT(): string | null {
const token = window.localStorage.getItem(TOKEN_STORAGE_KEY);
return token ?? null;
}
export function setJWT(jwt: string) {
window.localStorage.setItem(TOKEN_STORAGE_KEY, jwt);
}
export function clearJWT() {
window.localStorage.removeItem(TOKEN_STORAGE_KEY);
}