UNPKG

kawkab-frontend

Version:

Kawkab frontend is a frontend library for the Kawkab framework

21 lines (20 loc) 479 B
export class AuthManager { storage; tokenKey; constructor(storage, tokenKey = 'kawkab_auth_token') { this.storage = storage; this.tokenKey = tokenKey; } setToken(token) { this.storage.setItem(this.tokenKey, token); } getToken() { return this.storage.getItem(this.tokenKey); } clearToken() { this.storage.removeItem(this.tokenKey); } isAuthenticated() { return !!this.getToken(); } }