Initial Auth integration

This commit is contained in:
Barry Low committed 2018-10-11 14:53:58 -07:00
1 parent 27c32184b2
commit 401fb88e0e
8 files changed
+53 -158

No files matched your search

+8 -1
View File
@@ -19,7 +19,7 @@ export const auth = new Auth(
result => console.log('auth result', result),
client
)
console.log(Header)
export const MasterApp = () => (
<BrowserRouter>
<ApolloProvider client={client}>
@@ -29,6 +29,13 @@ export const MasterApp = () => (
<Header auth={auth} />
<Switch>
<Route exact path='/' component={Home} />
<Route
path='/callback'
render={props => {
auth.handleAuthentication(props)
return <Callback {...props} />
}}
/>
<Route
exact
path='/teams'
+1 -1
View File
@@ -10,7 +10,7 @@ import { AUTH_CONFIG } from './Auth0' // create by renaming Auth0.sample.js to A
const AUTHENTICATE = gql`
mutation authenticate($idToken: String!) {
authenticate(idToken: $idToken) {
TeamsModuleauthenticate(idToken: $idToken) {
alias
authId
}
+6 -4
View File
@@ -4,8 +4,8 @@ import { InMemoryCache } from 'apollo-cache-inmemory'
import { ApolloLink, split, Observable } from 'apollo-link'
import { onError } from 'apollo-link-error'
import { setContext } from 'apollo-link-context'
import { WebSocketLink } from 'apollo-link-ws'
import { SubscriptionClient } from 'subscriptions-transport-ws'
// import { WebSocketLink } from 'apollo-link-ws'
// import { SubscriptionClient } from 'subscriptions-transport-ws'
import { getMainDefinition } from 'apollo-utilities'
import { getItem } from '../utils/local-storage'
@@ -15,6 +15,7 @@ const graphqlEndpoint =
? process.env.PROD_GRAPHQL
: process.env.DEV_GRAPHQL
/*
const wsUri = graphqlEndpoint.replace(/^http/, 'ws')
const globalVar =
@@ -23,6 +24,7 @@ const globalVar =
: typeof window !== 'undefined'
? window
: {}
const webSocketImpl = globalVar.WebSocket || globalVar.MozWebSocket
const wsClient = new SubscriptionClient(
@@ -40,7 +42,7 @@ wsClient.onDisconnected(() => {
wsClient.onReconnected(() => {
// console.log('onReconnected')
})
*/
const httpLink = new HttpLink({ uri: graphqlEndpoint })
const link = split(
@@ -48,7 +50,7 @@ const link = split(
const { kind, operation } = getMainDefinition(query)
return kind === 'OperationDefinition' && operation === 'subscription'
},
new WebSocketLink(wsClient),
// new WebSocketLink(wsClient),
httpLink
)
+7
View File
@@ -0,0 +1,7 @@
import React from 'react'
import { MessageCard } from '@advancedalgos/web-components'
const Callback = () => <MessageCard message='Authenticating...' />
export default Callback
+15
View File
@@ -0,0 +1,15 @@
import React from 'react'
import PropTypes from 'prop-types'
import Button from '@material-ui/core/Button'
export const LoggedOut = ({ auth }) => (
<div onClick={() => auth.login()}>
<Button color='inherit'>Login / Sign up</Button>
</div>
)
LoggedOut.propTypes = {
auth: PropTypes.object.isRequired
}
export default LoggedOut
+1 -1
View File
@@ -93,7 +93,7 @@ class Header extends Component {
color='inherit'
className={classes.toolbarTitle}
>
Teams
&nbsp;
</Typography>
<IconButton