Created
July 22, 2021 13:52
-
-
Save kepi74/a253797fd85d8047f0c8c59bff6c4ae0 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains 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
const LoginMachine = Machine({ | |
id: 'loginMachine', | |
initial: 'credentialsForm', | |
states: { | |
credentialsForm: { | |
initial: 'iddle', | |
states: { | |
iddle: { | |
entry: ['parseAuthParamsFromQueryString', 'checkValidityOfAuthParams'], | |
on: { | |
SUBMIT_CREDENTIALS: { | |
target: 'submittingCredentials', | |
actions: ['storeCredentials'], | |
}, | |
}, | |
}, | |
submittingCredentials: { | |
invoke: { | |
src: 'logIn', | |
onDone: '#loginMachine.secondFactorForm', | |
onError: 'error', | |
}, | |
}, | |
error: {}, | |
}, | |
}, | |
secondFactorForm: { | |
states: { | |
initialize: { | |
invoke: { | |
src: 'initializeSecondFactor', | |
onDone: { | |
target: 'iddle', | |
actions: ['storeSecondFactorInitData'], | |
}, | |
onError: 'error', | |
}, | |
}, | |
iddle: { | |
on: { | |
SUBMIT_SECOND_FACTOR: { | |
target: 'submittingSecondFactor', | |
actions: ['storeSecondFactorCode'], | |
}, | |
}, | |
}, | |
submittingSecondFactor: { | |
invoke: { | |
src: 'secondFactor', | |
onDone: '#loginMachine.userAuthorized', | |
onError: 'error', | |
}, | |
}, | |
error: {}, | |
}, | |
}, | |
userAuthorized: { | |
invoke: { | |
src: 'proceedToApplication', | |
}, | |
type: 'final', | |
}, | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment