Skip to content

Commit 0fdcc15

Browse files
committed
chore: flatten an if statement in the helper method by adding mfaTypesForSetup in the first if statement
1 parent 66097f2 commit 0fdcc15

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/sign_in_state_machine.dart

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -658,18 +658,11 @@ final class SignInStateMachine
658658
required bool hasUserResponse,
659659
}) async {
660660
final allowedMfaTypes = _allowedMfaTypes;
661-
if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) {
662-
throw const InvalidUserPoolConfigurationException(
663-
'No MFA types are allowed for setup.',
664-
recoverySuggestion: 'Check your user pool MFA configuration.',
665-
);
666-
}
667-
668661
// Exclude MfaType.sms from consideration
669-
final mfaTypesForSetup = allowedMfaTypes.difference({MfaType.sms});
670-
if (mfaTypesForSetup.isEmpty) {
662+
final mfaTypesForSetup = allowedMfaTypes?.difference({MfaType.sms});
663+
if (allowedMfaTypes == null || allowedMfaTypes.isEmpty || mfaTypesForSetup == null || mfaTypesForSetup.isEmpty) {
671664
throw const InvalidUserPoolConfigurationException(
672-
'No eligible MFA types are available for setup.',
665+
'No eligible MFA types are allowed for setup.',
673666
recoverySuggestion: 'Check your user pool MFA configuration.',
674667
);
675668
}

0 commit comments

Comments
 (0)