Skip to content

Instantly share code, notes, and snippets.

@sdkcodes
Created August 26, 2018 11:43
Show Gist options
  • Select an option

  • Save sdkcodes/20098f1be79b48f9abb173ea3e15db11 to your computer and use it in GitHub Desktop.

Select an option

Save sdkcodes/20098f1be79b48f9abb173ea3e15db11 to your computer and use it in GitHub Desktop.
class Auth{
static isLoggedIn(){
return Auth.tokenPresent();
}
static tokenPresent(){
return Auth.getAuthToken() != null;
}
static getAuthToken(){
return localStorage.getItem("auth_token");
}
static logout(){
localStorage.clear();
}
static saveToken(token){
localStorage.setItem("auth_token", token);
}
static saveUser(user){
localStorage.setItem("user", JSON.stringify(user));
}
}
export default Auth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment