Skip to content

Commit 13e60c4

Browse files
committed
chore: update core docs
1 parent 86a3228 commit 13e60c4

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

packages/amplify_core/doc/lib/auth.dart

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,32 @@ Future<void> resendSignUpCode(String username) async {
104104
}
105105
// #enddocregion resend-signup-code
106106

107-
// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email
107+
// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup
108108
Future<void> _handleSignInResult(SignInResult result) async {
109109
switch (result.nextStep.signInStep) {
110-
// #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code
110+
// #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-email-code, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup
111111
// #docregion handle-confirm-signin-mfa-selection
112112
case AuthSignInStep.continueSignInWithMfaSelection:
113113
final allowedMfaTypes = result.nextStep.allowedMfaTypes!;
114114
final selection = await _promptUserPreference(allowedMfaTypes);
115115
return _handleMfaSelection(selection);
116116
// #enddocregion handle-confirm-signin-mfa-selection
117+
// #docregion handle-confirm-signin-mfa-setup-selection
118+
case AuthSignInStep.continueSignInWithMfaSetupSelection:
119+
final allowedMfaTypes = result.nextStep.allowedMfaTypes!;
120+
final selection = await _promptUserPreference(allowedMfaTypes);
121+
return _handleMfaSetupSelection(selection);
122+
// #enddocregion handle-confirm-signin-mfa-setup-selection
117123
// #docregion handle-confirm-signin-totp-setup
118124
case AuthSignInStep.continueSignInWithTotpSetup:
119125
final totpSetupDetails = result.nextStep.totpSetupDetails!;
120126
final setupUri = totpSetupDetails.getSetupUri(appName: 'MyApp');
121127
safePrint('Open URI to complete setup: $setupUri');
122128
// #enddocregion handle-confirm-signin-totp-setup
129+
// #docregion handle-confirm-signin-email-setup
130+
case AuthSignInStep.continueSignInWithEmailMfaSetup:
131+
safePrint('A confirmation code has been sent to your email');
132+
// #enddocregion handle-confirm-signin-email-setup
123133
// #docregion handle-confirm-signin-totp-code
124134
case AuthSignInStep.confirmSignInWithTotpMfaCode:
125135
safePrint('Enter a one-time code from your registered Authenticator app');
@@ -163,10 +173,10 @@ Future<void> _handleSignInResult(SignInResult result) async {
163173
case AuthSignInStep.done:
164174
safePrint('Sign in is complete');
165175
// #enddocregion handle-confirm-signin-done
166-
// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code
176+
// #docregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup
167177
}
168178
}
169-
// #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code
179+
// #enddocregion handle-signin, handle-confirm-signin-sms, handle-confirm-signin-new-password, handle-confirm-signin-custom-challenge, handle-confirm-signin-reset-password, handle-confirm-signin-confirm-signup, handle-confirm-signin-done, handle-confirm-signin-mfa-selection, handle-confirm-signin-totp-setup, handle-confirm-signin-totp-code, handle-confirm-signin-email-code, handle-confirm-signin-mfa-setup-selection, handle-confirm-signin-email-setup
170180

171181
// #docregion signin
172182
Future<void> signInUser(String username, String password) async {
@@ -241,6 +251,19 @@ Future<void> _handleMfaSelection(MfaType selection) async {
241251
}
242252
// #enddocregion handle-mfa-selection
243253

254+
// #docregion handle-mfa-setup-selection
255+
Future<void> _handleMfaSetupSelection(MfaType selection) async {
256+
try {
257+
final result = await Amplify.Auth.confirmSignIn(
258+
confirmationValue: selection.confirmationValue,
259+
);
260+
return _handleSignInResult(result);
261+
} on AuthException catch (e) {
262+
safePrint('Error resending code: ${e.message}');
263+
}
264+
}
265+
// #enddocregion handle-mfa-setup-selection
266+
244267
// #docregion signout
245268
Future<void> signOutCurrentUser() async {
246269
final result = await Amplify.Auth.signOut();

0 commit comments

Comments
 (0)