23 lines
458 B
TypeScript
23 lines
458 B
TypeScript
const TOKEN_KEY = 'gold-land-auth-token'
|
|
|
|
let authToken: string | null = null
|
|
|
|
export function getAuthToken(): string | null {
|
|
if (authToken) return authToken
|
|
try {
|
|
return localStorage.getItem(TOKEN_KEY)
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
export function setAuthToken(token: string | null) {
|
|
authToken = token
|
|
try {
|
|
if (token) localStorage.setItem(TOKEN_KEY, token)
|
|
else localStorage.removeItem(TOKEN_KEY)
|
|
} catch {
|
|
// ignore
|
|
}
|
|
}
|