Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const requireAuthentication = UserAuthWrapper({
- authSelector: state => state.auth,
- authenticatingSelector: state => state.auth.isAuthenticating,
- predicate: auth => auth.isAuthenticated,
- redirectAction: push,
- wrapperDisplayName: 'UserIsJWTAuthenticated',
- allowRedirectBack: false
- });
- const userIsAdmin = UserAuthWrapper({
- authSelector: state => state.auth,
- redirectAction: push,
- failureRedirectPath: '/customer/' + localStorage.getItem("customerId"),
- wrapperDisplayName: 'UserIsAdmin',
- predicate: auth => auth.isAdmin,
- allowRedirectBack: false
- });
- const router = (
- <Router onUpdate={() => window.scrollTo(0, 0)} history={history}>
- <Route path="/" component={App}>
- <IndexRoute component={requireAuthentication(userIsAdmin(Customers))}/>
- <Route path="/login" component={Login}/>
- <Route path="/invite_customer" component={requireAuthentication(userIsAdmin(CustomerInvite))}/>
- <Route path="/exercise_bank" component={requireAuthentication(userIsAdmin(ExerciseBank))}/>
- <Route path="/customer/:id" component={requireAuthentication(Customer)}/>
- <Route path="*" component={NotFound}/>
- </Route>
- </Router>
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement