mirror of
https://github.com/koel/koel
synced 2024-12-25 20:13:06 +00:00
22 lines
401 B
TypeScript
22 lines
401 B
TypeScript
|
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)
|
||
|
}
|
||
|
}
|