Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 19th, 2018 74 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. const enforceUserAuth = {
  2.   authenticate() {
  3.     API.get('user/authed', {}, res => {
  4.       debugger;
  5.       this.isAuthenticated = res.authed;
  6.     })
  7.   }
  8. }
  9.    
  10. function PrivateRoute({ component: Component, ...rest }) {
  11.   return(
  12.     <Route {...rest}
  13.            render={props => enforceUserAuth.isAuthenticated ?
  14.                               (<Component {...props} />) :
  15.                               (<Redirect to={{ pathname: '/login',
  16.                                                state: { source: props.location } }} />)
  17.                   }
  18.     />
  19.   )
  20. }
  21.    
  22. function enforceUserAuth() {
  23.   let validUser = false;
  24.   API.get('user/authed', {}, res => {
  25.     validUser = res.authed
  26.     return validUser;
  27.   })
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top