Created
March 24, 2019 19:19
-
-
Save karannaoh/97fdea5a266e2e83b22e638bcafb7fc1 to your computer and use it in GitHub Desktop.
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
import React from 'react'; | |
import { Route, Router } from 'react-router-dom'; | |
import Callback from './Callback'; | |
import Auth from './Auth'; | |
import history from './history'; | |
import Login from './Login' | |
import App from './App'; | |
import Logout from './Logout' | |
const auth = new Auth(); | |
const handleAuthentication = ({location}) => { | |
if (/access_token|id_token|error/.test(location.hash)) { | |
auth.handleAuthentication(); | |
} | |
} | |
export const route = () => { | |
return ( | |
<Router history={history}> | |
<div> | |
<Route exact path="/app" render={(props) => <App auth={auth} {...props} />} /> | |
<Route exact path="/" render={(props) => <Login auth={auth} {...props}/>} /> | |
<Route exact path="/logout" render={(props) => <Logout auth={auth} {...props}/>} /> | |
<Route exact path="/callback" render={(props) => { | |
handleAuthentication(props); | |
return <Callback {...props} /> | |
}}/> | |
</div> | |
</Router> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment