Skip to content

Feature/auth #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
complete authorization
  • Loading branch information
ShMcK committed Oct 6, 2019
commit 8b32f1884307c226e9a5bf0e4e891d94086bd65e
4 changes: 2 additions & 2 deletions web-app/src/components/ErrorBoundary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class ErrorBoundary extends React.Component {
// Display fallback UI
this.setState({ hasError: true })
// You can also log the error to an error reporting service
console.error(error)
console.log(info)
console.error(JSON.stringify(error))
console.log(JSON.stringify(info))
}

public render() {
Expand Down
12 changes: 7 additions & 5 deletions web-app/src/services/apollo/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export const setAuthToken = (token: string | null) => {
}

export const authorizeHeaders = (operation: Operation) => {
operation.setContext({
headers: {
token: authToken
}
})
if (authToken) {
operation.setContext({
headers: {
'Authorization': authToken
}
})
}
}
4 changes: 3 additions & 1 deletion web-app/src/services/state/actions/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import channel from '../../../services/channel'

export default {
authenticate: (async (context: CR.MachineContext): Promise<void> => {

const result = await client.mutate({
mutation: authenticateMutation,
variables: {
Expand All @@ -15,9 +16,10 @@ export default {
}
})


if (!result || !result.data) {
// TODO: handle failed authentication
console.log('unauthenticated')
console.error('ERROR: Authentication failed')
}
const {token} = result.data.editorLogin
// add token to headers
Expand Down
5 changes: 4 additions & 1 deletion web-app/src/services/state/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import * as selectors from '../../selectors'
export default {
setEnv: assign({
env: (context: CR.MachineContext, event: CR.MachineEvent) => {
return event.payload.env
return {
...context.env,
...event.payload.env
}
}
}),
continueTutorial: assign({
Expand Down