koel/resources/assets/js/services/authService.ts

22 lines
401 B
TypeScript
Raw Normal View History

2022-04-24 08:50:45 +00:00
import { localStorageService } from '.'
export const authService = {
storageKey: 'api-token',
getToken () {
return localStorageService.get<string | null>(this.storageKey)
},
hasToken () {
return Boolean(this.getToken())
},
setToken (token: string) {
localStorageService.set(this.storageKey, token)
},
destroy () {
localStorageService.remove(this.storageKey)
}
}