Skip to content

Commit

Permalink
chore: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jjarvisp committed Feb 21, 2025
1 parent 9f70329 commit ba0aa21
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/helpers/authenticator/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export const getServiceContextFacade = (
})(route);

const facade = {
allowedMfaTypes,
authStatus,
challengeName,
codeDeliveryDetails,
Expand All @@ -230,7 +231,6 @@ export const getServiceContextFacade = (
user,
username,
validationErrors,
allowedMfaTypes,

// @v6-migration-note
// While most of the properties
Expand Down
57 changes: 24 additions & 33 deletions packages/ui/src/machines/authenticator/actors/signIn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ const handleFetchUserAttributesResponse = {
},
};

const defaultState = {
const getDefaultConfirmSignInState = (exit: string[]) => ({
initial: 'edit',
exit: ['clearFormValues', 'clearError', 'clearTouched'],
exit,
states: {
edit: {
entry: 'sendUpdate',
Expand All @@ -99,7 +99,7 @@ const defaultState = {
invoke: { src: 'confirmSignIn', ...handleSignInResponse },
},
},
};
});

export function signInActor({ services }: SignInMachineOptions) {
return createMachine<SignInContext, AuthEvent>(
Expand Down Expand Up @@ -187,33 +187,12 @@ export function signInActor({ services }: SignInMachineOptions) {
},
},
},
confirmSignIn: {
initial: 'edit',
exit: [
'clearChallengeName',
'clearFormValues',
'clearError',
'clearTouched',
],
states: {
edit: {
entry: 'sendUpdate',
on: {
SUBMIT: { actions: 'handleSubmit', target: 'submit' },
SIGN_IN: '#signInActor.signIn',
CHANGE: { actions: 'handleInput' },
},
},
submit: {
tags: 'pending',
entry: ['clearError', 'sendUpdate'],
invoke: {
src: 'confirmSignIn',
...handleSignInResponse,
},
},
},
},
confirmSignIn: getDefaultConfirmSignInState([
'clearChallengeName',
'clearFormValues',
'clearError',
'clearTouched',
]),
forceChangePassword: {
entry: 'sendUpdate',
type: 'parallel',
Expand Down Expand Up @@ -286,9 +265,21 @@ export function signInActor({ services }: SignInMachineOptions) {
},
},
},
setupTotp: defaultState,
setupEmail: defaultState,
selectMfaType: defaultState,
setupTotp: getDefaultConfirmSignInState([
'clearFormValues',
'clearError',
'clearTouched',
]),
setupEmail: getDefaultConfirmSignInState([
'clearFormValues',
'clearError',
'clearTouched',
]),
selectMfaType: getDefaultConfirmSignInState([
'clearFormValues',
'clearError',
'clearTouched',
]),
resolved: {
type: 'final',
data: (context): ActorDoneData => ({
Expand Down

0 comments on commit ba0aa21

Please sign in to comment.