8000 complete authentication on client · jordanliu/coderoad-vscode@9cfa2e7 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9cfa2e7

Browse files
committed
complete authentication on client
1 parent 0a1e9ee commit 9cfa2e7

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

web-app/src/services/channel/index.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,17 @@ class Channel {
3838
// messages from core
3939
switch (action.type) {
4040
case 'ENV_LOAD':
41-
this.machineSend(action)
42-
return
41+
case 'AUTHENTICATED':
4342
case 'TUTORIAL_LOADED':
44-
// send action to state machine
45-
this.machineSend('TUTORIAL_LOADED')
46-
console.log('send action to state machine')
47-
return
4843
case 'NEW_TUTORIAL':
49-
this.machineSend(action)
50-
return
5144
case 'TUTORIAL_CONFIGURED':
52-
this.machineSend(action)
53-
return
5445
case 'CONTINUE_TUTORIAL':
55-
this.machineSend(action)
56-
return
5746
case 'TEST_PASS':
58-
// { type: 'TEST_PASS', payload: { stepId: string }}
59-
this.machineSend(action)
60-
return
6147
case 'TEST_FAIL':
62-
this.machineSend(action)
63-
return
6448
case 'TEST_RUNNING':
65-
this.machineSend(action)
66-
return
6749
case 'TEST_ERROR':
68-
console.log('TEST_ERROR')
6950
this.machineSend(action)
7051
return
71-
case 'ACTIONS_LOADED':
72-
// TODO: use this for verifying completion of stepActions
73-
return
7452
default:
7553
if (action.type) {
7654
console.warn(`Unknown received action ${action.type}`, action)

web-app/src/services/state/actions/api.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import * as CR from 'typings'
22
import client from '../../apollo'
33
import authenticateMutation from '../../apollo/mutations/authenticate'
44
import {setAuthToken} from '../../apollo/auth'
5-
import {send} from 'xstate'
5+
import channel from '../../../services/channel'
66

77
export default {
8-
authenticate: (async (context: CR.MachineContext): Promise<CR.Action> => {
8+
authenticate: (async (context: CR.MachineContext): Promise<void> => {
99
const result = await client.mutate({
1010
mutation: authenticateMutation,
1111
variables: {
@@ -20,9 +20,10 @@ export default {
2020
console.log('unauthenticated')
2121
}
2222
const {token} = result.data.editorLogin
23-
console.log(token)
23+
// add token to headers
2424
setAuthToken(token)
25-
return send({type: 'AUTHENTICATED'})
25+
// pass authenticated action back to state machine
26+
channel.receive({data: {type: 'AUTHENTICATED'}})
2627
}),
2728
userTutorialComplete(context: CR.MachineContext) {
2829
console.log('should update user tutorial as complete')

0 commit comments

Comments
 (0)
0