Created
August 26, 2018 11:43
-
-
Save sdkcodes/20098f1be79b48f9abb173ea3e15db11 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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