Skip to content

Instantly share code, notes, and snippets.

@hamiltondanielb
Created July 14, 2016 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamiltondanielb/3f211c6663dfa0784be9fa5d4203e412 to your computer and use it in GitHub Desktop.
Save hamiltondanielb/3f211c6663dfa0784be9fa5d4203e412 to your computer and use it in GitHub Desktop.
React Authorization
function isLoggedIn() {
return localStorage.getItem('id_token');
}
export function requireAuth(nextState, replace) {
if (!isLoggedIn()) {
replace({
pathname: '/login',
state: { nextPathname: nextState.location.pathname }
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment