koel/resources/assets/js/services/auth.ts
2022-04-15 16:24:30 +02:00

21 lines
362 B
TypeScript

import { ls } from '.'
export const auth = {
storageKey: 'api-token',
getToken (): string | null {
return ls.get<string | null>(this.storageKey)
},
hasToken (): boolean {
return Boolean(this.getToken())
},
setToken (token: string): void {
ls.set(this.storageKey, token)
},
destroy (): void {
ls.remove(this.storageKey)
}
}