You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Set mfaPreference to EMAIL when using email-only MFA
271
+
const user =awaitcreateAndSignUpUser({
272
+
username: username,
273
+
password: password,
274
+
signInAfterCreation: false,
275
+
signInFlow: "MFA",
276
+
mfaPreference: "EMAIL",
277
+
});
278
+
279
+
// Sign in will prompt for MFA code in command line
280
+
awaitsignInUser({
281
+
username: username,
282
+
password: password,
283
+
signInFlow: "MFA",
284
+
});
285
+
286
+
auth.signOut();
287
+
```
288
+
289
+
This will create a user with the username and password with Email MFA enabled. The user will then be signed in and prompted for the MFA code in the command line.
SMS MFA follows the same pattern as Email MFA, using command line prompts for verification. Just replace `mfaPreference: "EMAIL"` with `mfaPreference: "SMS"` in your configuration. The command line experience will be identical, prompting for the SMS code instead of the email code.
301
+
302
+
<Calloutinfo>
303
+
**Note:** Email-based MFA is currently not supported with `defineAuth`. We are working towards supporting this feature. For more information, visit the [feature request in GitHub](https://github.com/aws-amplify/amplify-backend/issues/2159).
304
+
305
+
To take advantage of this feature with an Amplify generated backend, the underlying CDK construct can be extended manually. See [overriding Cognito User Pool multi-factor authentication options](/[platform]/build-a-backend/auth/modify-resources-with-cdk/#override-cognito-userpool-multi-factor-authentication-options) for more information.
306
+
</Callout>
307
+
248
308
### Data
249
309
250
310
For example, if you like to seed your Data API, lets start by creating a GraphQL API with a `Todo` model with authorization mode set to `userPool`:
@@ -459,14 +519,16 @@ This behavior is particularly important when seeding multiple users in your appl
459
519
460
520
### MFA Challenge Handling
461
521
462
-
- For sign-up challenges, each MFA type has its specific challenge callback:
522
+
- For sign-up challenges, each MFA type has its own specific challenge callback:
463
523
- TOTP: `totpSignUpChallenge`
464
524
- Email: `emailSignUpChallenge`
465
-
466
-
- For sign-in, there's a single `signInChallenge` callback that works for all MFA types
525
+
- SMS: `smsSignUpChallenge`
526
+
527
+
- For sign-in, there's a single universal `signInChallenge` callback that works with all MFA types (TOTP, Email, or SMS)
467
528
468
-
- Command line prompts work with all forms of MFA during sign-in
469
-
- For sign-up, command line prompts work with EMAIL and SMS, but not with TOTP
529
+
Important behaviors:
530
+
- Command line prompts work with all MFA types during sign-in
531
+
- During sign-up, command line will prompt for EMAIL and SMS MFA, but not for TOTP MFA
470
532
- When MFA is set to "Optional" in a user pool, users will be sent through the Password flow
471
533
472
534
### TOTP Considerations
@@ -530,20 +592,17 @@ Auth APIs allow you to create and manage users in your sandbox environment and a
530
592
}, 'GroupName');
531
593
```
532
594
533
-
### Additional APIs
595
+
### Additional Types
534
596
535
-
The `@aws-amplify/seed` package additionally provides the following APIs:
597
+
The `@aws-amplify/seed` package provides these essential types:
536
598
537
-
-`AuthSignUp` - API for user sign-up configuration
538
-
-`AuthUser` - API for user authentication information
539
-
-`ChallengeResponse` - API for MFA challenge responses
540
-
-`StandardUserAttributes` - API for managing user attributes during sign-up
541
-
-`PasswordSignInFlow` - API for password-based authentication
542
-
-`MfaSignUpFlow` - API for MFA during sign-up
543
-
-`MfaSignInFlow` - API for MFA during sign-in
544
-
-`MfaWithTotpSignUpFlow` - API for TOTP-specific MFA during sign-up
599
+
-`AuthSignUp` - Type for user sign-up configuration
600
+
-`AuthUser` - Type for user authentication information
601
+
-`ChallengeResponse` - Type for MFA challenge responses
602
+
-`StandardUserAttributes` - Type for managing user attributes during sign-up
603
+
-`AuthOutputs` - Type for user sign-up output
545
604
546
-
The following challenge callback APIs are available for MFA flows:
605
+
MFA challenge callback types:
547
606
-`emailSignUpChallenge` - Handles Email MFA during sign-up
548
607
-`smsSignUpChallenge` - Handles SMS MFA during sign-up
549
608
-`totpSignUpChallenge` - Handles TOTP MFA during sign-up
0 commit comments