function TokenService(){} TokenService.prototype = { TOKEN : 'TOKEN-SEBRAE-GO', setToken : function(token){ localStorage.setItem(this.TOKEN,token); }, getToken : function(){ return localStorage.getItem(this.TOKEN); }, hasToken : function (){ return !!this.getToken(); }, removeToken:function(){ localStorage.removeItem(this.TOKEN); }, getTokenDecoded : function(){ var token = this.getToken(); if ( token ) { var base64Url = token.split('.')[1]; var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/'); return JSON.parse(window.atob(base64)); } return null; } }