Skip to content

Commit

Permalink
docs(auth): Update TOTP snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillon Nys authored and dnys1 committed Aug 24, 2023
1 parent 6702387 commit 4d50bb1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
6 changes: 5 additions & 1 deletion packages/amplify_core/doc/lib/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,15 @@ Future<void> confirmMfaUser(String mfaCode) async {
}
// #enddocregion confirm-signin

// #docregion handle-mfa-selection
// #docregion prompt-user-preference
Future<MfaType> _promptUserPreference(Set<MfaType> allowedTypes) async {
// #enddocregion prompt-user-preference
throw UnimplementedError();
// #docregion prompt-user-preference
}
// #enddocregion prompt-user-preference

// #docregion handle-mfa-selection
Future<void> _handleMfaSelection(MfaType selection) async {
try {
final result = await Amplify.Auth.confirmSignIn(
Expand Down
19 changes: 12 additions & 7 deletions packages/amplify_core/lib/src/category/amplify_auth_category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,19 @@ class AuthCategory extends AmplifyCategory<AuthPluginInterface> {
/// If both SMS MFA and TOTP MFA are enabled and configured for the user, they will be
/// given the choice of which mechanism they'd like to use to continue signing in.
///
/// <?code-excerpt "doc/lib/auth.dart" region="handle-mfa-selection"?>
/// <?code-excerpt "doc/lib/auth.dart" region="prompt-user-preference"?>
/// ```dart
/// Future<MfaType> _promptUserPreference(Set<MfaType> allowedTypes) async {
/// throw UnimplementedError();
/// // ···
/// }
/// ```
///
/// <?code-excerpt "doc/lib/auth.dart" region="handle-mfa-selection"?>
/// ```dart
/// Future<void> _handleMfaSelection(MfaType selection) async {
/// try {
/// final result = await Amplify.Auth.confirmSignIn(
/// confirmationValue: selection.name,
/// confirmationValue: selection.confirmationValue,
/// );
/// return _handleSignInResult(result);
/// } on AuthException catch (e) {
Expand Down Expand Up @@ -1296,11 +1299,13 @@ class AuthCategory extends AmplifyCategory<AuthPluginInterface> {
/// Initiates setup of a time-based one-time passcode (TOTP) MFA method for the
/// current user.
///
/// Your backend must be set up with TOTP MFA enabled prior to calling this method.
/// **NOTE**: Your backend must be set up with TOTP MFA enabled prior to calling this method.
///
/// The [TotpSetupDetails] returned contains a [TotpSetupDetails.getSetupUri]
/// method which can be used to display a QR code or render a button to open
/// the user's installed authenticator app. After setup is complete on the user's
/// end, call [verifyTotpSetup] with a one-time code to complete registration.
/// method for retrieving the setup URI. This can be used to build a QR code or
/// a button which opens the user's installed authenticator app. After setup is
/// complete on the user's end, call [verifyTotpSetup] with a one-time code to
/// complete registration.
/// {@endtemplate}
Future<TotpSetupDetails> setUpTotp({
TotpSetupOptions? options,
Expand Down

0 comments on commit 4d50bb1

Please sign in to comment.