May 2018
Intermediate to advanced
470 pages
13h 54m
English
In client/auth/auth-helper.js, we will define the following helper methods to store and retrieve JWT credentials from client-side sessionStorage, and also clear out the sessionStorage on user sign-out:
authenticate(jwt, cb) { if(typeof window !== "undefined") sessionStorage.setItem('jwt', JSON.stringify(jwt)) cb()}
isAuthenticated() { if (typeof window == "undefined") return false if (sessionStorage.getItem('jwt')) return JSON.parse(sessionStorage.getItem('jwt')) else return false}
signout(cb) { if(typeof window !== "undefined") sessionStorage.removeItem('jwt') ...Read now
Unlock full access