@@ -330,56 +330,55 @@ final class SignInStateMachine
330
330
createEmailMfaRequest (event),
331
331
ChallengeNameType .selectMfaType when hasUserResponse =>
332
332
createSelectMfaRequest (event),
333
- ChallengeNameType .mfaSetup =>
334
- (() async {
335
- final allowedMfaTypes = _allowedMfaTypes;
336
- if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) {
337
- throw const InvalidUserPoolConfigurationException (
338
- 'No MFA types are allowed for setup.' ,
339
- recoverySuggestion: 'Check your user pool MFA configuration.' ,
340
- );
341
- }
342
- // Exclude MfaType.sms from consideration
343
- final mfaTypesForSetup = allowedMfaTypes.difference ({MfaType .sms});
344
- if (mfaTypesForSetup.isEmpty) {
345
- throw const InvalidUserPoolConfigurationException (
346
- 'No eligible MFA types are available for setup.' ,
347
- recoverySuggestion: 'Check your user pool MFA configuration.' ,
348
- );
349
- }
350
- if (mfaTypesForSetup.length == 1 ) {
351
- final mfaType = mfaTypesForSetup.first;
352
- if (mfaType == MfaType .totp) {
353
- _enableMfaType = MfaType .totp;
354
- _totpSetupResult ?? = await associateSoftwareToken ();
355
- if (hasUserResponse) {
356
- return createMfaSetupRequest (event);
357
- } else {
358
- // Need to prompt user for the TOTP code
359
- return null ;
360
- }
361
- } else if (mfaType == MfaType .email) {
362
- _enableMfaType = MfaType .email;
363
- if (hasUserResponse) {
364
- return createEmailMfaSetupRequest (event);
333
+ ChallengeNameType .mfaSetup => (() async {
334
+ final allowedMfaTypes = _allowedMfaTypes;
335
+ if (allowedMfaTypes == null || allowedMfaTypes.isEmpty) {
336
+ throw const InvalidUserPoolConfigurationException (
337
+ 'No MFA types are allowed for setup.' ,
338
+ recoverySuggestion: 'Check your user pool MFA configuration.' ,
339
+ );
340
+ }
341
+ // Exclude MfaType.sms from consideration
342
+ final mfaTypesForSetup = allowedMfaTypes.difference ({MfaType .sms});
343
+ if (mfaTypesForSetup.isEmpty) {
344
+ throw const InvalidUserPoolConfigurationException (
345
+ 'No eligible MFA types are available for setup.' ,
346
+ recoverySuggestion: 'Check your user pool MFA configuration.' ,
347
+ );
348
+ }
349
+ if (mfaTypesForSetup.length == 1 ) {
350
+ final mfaType = mfaTypesForSetup.first;
351
+ if (mfaType == MfaType .totp) {
352
+ _enableMfaType = MfaType .totp;
353
+ _totpSetupResult ?? = await associateSoftwareToken ();
354
+ if (hasUserResponse) {
355
+ return createMfaSetupRequest (event);
356
+ } else {
357
+ // Need to prompt user for the TOTP code
358
+ return null ;
359
+ }
360
+ } else if (mfaType == MfaType .email) {
361
+ _enableMfaType = MfaType .email;
362
+ if (hasUserResponse) {
363
+ return createEmailMfaSetupRequest (event);
364
+ } else {
365
+ // Need to prompt user for the email verification code
366
+ return null ;
367
+ }
365
368
} else {
366
- // Need to prompt user for the email verification code
367
- return null ;
369
+ throw InvalidUserPoolConfigurationException (
370
+ 'Unsupported MFA type: ${mfaType .name }' ,
371
+ recoverySuggestion: 'Check your user pool MFA configuration.' ,
372
+ );
368
373
}
374
+ } else if (hasUserResponse) {
375
+ // Handle user's selection
376
+ return createMfaSetupRequest (event);
369
377
} else {
370
- throw InvalidUserPoolConfigurationException (
371
- 'Unsupported MFA type: ${mfaType .name }' ,
372
- recoverySuggestion: 'Check your user pool MFA configuration.' ,
373
- );
378
+ // Need to prompt user to select an MFA type
379
+ return null ;
374
380
}
375
- } else if (hasUserResponse) {
376
- // Handle user's selection
377
- return createMfaSetupRequest (event);
378
- } else {
379
- // Need to prompt user to select an MFA type
380
- return null ;
381
- }
382
- })(),
381
+ })(),
383
382
ChallengeNameType .newPasswordRequired when hasUserResponse =>
384
383
createNewPasswordRequest (event),
385
384
_ => null ,
0 commit comments