Skip to content

Commit 6de4283

Browse files
Merge branch 'feat/email-otp-mfa' into feat/email-otp-tests
2 parents 1d03046 + 0500755 commit 6de4283

File tree

1 file changed

+8
-15
lines changed
  • packages/authenticator/amplify_authenticator/lib/src/blocs/auth

1 file changed

+8
-15
lines changed

packages/authenticator/amplify_authenticator/lib/src/blocs/auth/auth_bloc.dart

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class StateMachineBloc
234234
allowedMfaTypes: result.nextStep.allowedMfaTypes,
235235
);
236236
case AuthSignInStep.continueSignInWithMfaSetupSelection:
237-
await _handleMfaSetupSelection(result);
237+
yield await _handleMfaSetupSelection(result);
238238
case AuthSignInStep.continueSignInWithTotpSetup:
239239
assert(
240240
result.nextStep.totpSetupDetails != null,
@@ -340,7 +340,7 @@ class StateMachineBloc
340340
),
341341
);
342342
case AuthSignInStep.continueSignInWithMfaSetupSelection:
343-
await _handleMfaSetupSelection(result);
343+
_emit(await _handleMfaSetupSelection(result));
344344
case AuthSignInStep.continueSignInWithEmailMfaSetup:
345345
_emit(UnauthenticatedState.continueSignInWithEmailMfaSetup);
346346
case AuthSignInStep.confirmSignInWithTotpMfaCode:
@@ -543,7 +543,7 @@ class StateMachineBloc
543543
yield* const Stream.empty();
544544
}
545545

546-
Future<void> _handleMfaSetupSelection(SignInResult result) async {
546+
Future<UnauthenticatedState> _handleMfaSetupSelection(SignInResult result) async {
547547
final allowedMfaTypes = result.nextStep.allowedMfaTypes;
548548

549549
if (allowedMfaTypes == null) {
@@ -556,12 +556,7 @@ class StateMachineBloc
556556
final mfaTypesForSetup = allowedMfaTypes.toSet()..remove(MfaType.sms);
557557

558558
if (mfaTypesForSetup.length != 1) {
559-
_emit(
560-
ContinueSignInWithMfaSetupSelection(
561-
allowedMfaTypes: allowedMfaTypes,
562-
),
563-
);
564-
return;
559+
return ContinueSignInWithMfaSetupSelection(allowedMfaTypes: allowedMfaTypes);
565560
}
566561

567562
final mfaType = mfaTypesForSetup.first;
@@ -572,15 +567,13 @@ class StateMachineBloc
572567
result.nextStep.totpSetupDetails != null,
573568
'Sign In Result should have totpSetupDetails',
574569
);
575-
_emit(
576-
await ContinueSignInTotpSetup.setupURI(
577-
result.nextStep.totpSetupDetails!,
578-
totpOptions,
579-
),
570+
return ContinueSignInTotpSetup.setupURI(
571+
result.nextStep.totpSetupDetails!,
572+
totpOptions,
580573
);
581574

582575
case MfaType.email:
583-
_emit(UnauthenticatedState.continueSignInWithEmailMfaSetup);
576+
return UnauthenticatedState.continueSignInWithEmailMfaSetup;
584577

585578
default:
586579
throw InvalidUserPoolConfigurationException(

0 commit comments

Comments
 (0)