Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const enforceUserAuth = {
- authenticate() {
- API.get('user/authed', {}, res => {
- debugger;
- this.isAuthenticated = res.authed;
- })
- }
- }
- function PrivateRoute({ component: Component, ...rest }) {
- return(
- <Route {...rest}
- render={props => enforceUserAuth.isAuthenticated ?
- (<Component {...props} />) :
- (<Redirect to={{ pathname: '/login',
- state: { source: props.location } }} />)
- }
- />
- )
- }
- function enforceUserAuth() {
- let validUser = false;
- API.get('user/authed', {}, res => {
- validUser = res.authed
- return validUser;
- })
- }
Add Comment
Please, Sign In to add comment