Auth0 client integration ready

This commit is contained in:
Luis Fernando Molina committed 2018-09-06 20:34:06 +02:00
1 parent 3f9423e91d
commit eca2e6deff
12 files changed
+614 -10

No files matched your search

+32 -1
View File
@@ -1,6 +1,9 @@
import React, { Component } from 'react';
import ApolloClient from 'apollo-boost';
import {ApolloProvider} from 'react-apollo';
import { ApolloLink } from 'apollo-link';
import { HttpLink } from 'apollo-link-http'
import { setContext } from 'apollo-link-context';
import { Route, BrowserRouter, Switch } from 'react-router-dom'
@@ -16,13 +19,37 @@ import About from './components/About'
import Contact from './components/Contact'
import Post from './components/Post'
import Footer from './components/Footer'
import Callback from './components/Callback'
import Auth from './auth/index'
/*
const httpLink = new HttpLink({ uri: 'http://localhost:4000/graphql', changeOrigin: true })
// Apollo Client Setup
const client = new ApolloClient({
const authLink = setContext((_, { headers }) => {
// get the authentication token from local storage if it exists
const token = localStorage.getItem('access_token')
// return the headers to the context so httpLink can read them
return {
headers: {
...headers,
Authorization: token ? `Bearer ${token}` : ``
}
}
})
export const client = new ApolloClient({
link: httpLink
})
*/
export const client = new ApolloClient({
uri:'http://localhost:4000/graphql'
})
export const auth = new Auth(result => console.log('auth result', result), client);
class App extends Component {
render() {
@@ -40,6 +67,10 @@ class App extends Component {
<Route path='/about' component={About} />
<Route path='/contact' component={Contact} />
<Route path='/:post_id' component={Post} />
<Route path='/callback' render={(props) => {
auth.handleAuthentication(props)
return <Callback {...props} />
}}/>
</Switch>
<Footer/>
</div>