Created
July 14, 2016 16:34
-
-
Save hamiltondanielb/3f211c6663dfa0784be9fa5d4203e412 to your computer and use it in GitHub Desktop.
React Authorization
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
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