koel/resources/assets/js/services/authService.ts
2022-05-14 20:49:45 +02:00

14 lines
377 B
TypeScript

import { localStorageService } from '@/services'
const STORAGE_KEY = 'api-token'
export const authService = {
getToken: () => localStorageService.get<string | null>(STORAGE_KEY),
hasToken () {
return Boolean(this.getToken())
},
setToken: (token: string) => localStorageService.set(STORAGE_KEY, token),
destroy: () => localStorageService.remove(STORAGE_KEY)
}