export const TOKEN_KEY = 'auth_token'
export const SESSION_KEY = 'auth_session'

export const getToken = () => localStorage.getItem(TOKEN_KEY) || ''
export const setToken = (token: string) => localStorage.setItem(TOKEN_KEY, token)
export const clearToken = () => localStorage.removeItem(TOKEN_KEY)

export const setSessionAuth = (v: boolean) => localStorage.setItem(SESSION_KEY, v ? '1' : '')
export const hasSessionAuth = () => localStorage.getItem(SESSION_KEY) === '1'

export const isAuthenticated = () => !!getToken() || hasSessionAuth()
