Last active
February 24, 2020 17:30
-
-
Save GeneralistDev/9f612f60247ed29546fbe05f472ea558 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) | |
const needsTwoFactor = () => { | |
return true; | |
}; | |
const needsChangePassword = () => { | |
return true; | |
}; | |
const needsEnrollment = () => { | |
return true; | |
}; | |
const fetchMachine = Machine({ | |
id: 'auth', | |
initial: 'login', | |
states: { | |
login: { | |
on: { | |
SUCCESS: [ | |
{ | |
target: 'twofactor', | |
cond: needsTwoFactor | |
}, | |
{ | |
target: 'changepassword', | |
cond: needsChangePassword | |
}, | |
{ | |
target: 'enrollment', | |
cond: needsEnrollment | |
}, | |
{ | |
target: 'success' | |
} | |
] | |
} | |
}, | |
twofactor: { | |
on: { | |
SUCCESS: [ | |
{ | |
target: 'changepassword', | |
cond: needsChangePassword | |
}, | |
{ | |
target: 'enrollment', | |
cond: needsEnrollment | |
}, | |
{ | |
target: 'success' | |
} | |
] | |
} | |
}, | |
changepassword: { | |
on: { | |
SUCCESS: [ | |
{ | |
target: 'enrollment', | |
cond: needsEnrollment | |
}, | |
{ | |
target: 'success' | |
} | |
] | |
} | |
}, | |
enrollment: { | |
on: { | |
SUCCESS: [ | |
{ | |
target: 'success' | |
} | |
] | |
} | |
}, | |
success: { | |
type: 'final' | |
}, | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment