aws-amplify / docs

AWS Amplify Framework Documentation
https://docs.amplify.aws
Apache License 2.0
487 stars 1.06k forks source link

Code sample for MFA is broken #5844

Open salihgueler opened 1 year ago

salihgueler commented 1 year ago

Describe the bug Code sample below is broken on the link here

Current Code

Future<SignInResult> signInWithCognito(
  String username,
  String password,
) async {
  final SignInResult result = await Amplify.Auth.signIn(
    username: username, 
    password: password,
  );
  return _handleSignInResult(result);
}

Future<void> _handleSignInResult(SignInResult result) async {
  switch (result.nextStep.signInStep) {
    case AuthSignInStep.continueSignInWithMfaSelection:
      // Handle select from MFA methods case
    case AuthSignInStep.continueSignInWithTotpSetup:
      // Handle TOTP setup case
    case AuthSignInStep.confirmSignInWithTotpMfaCode:
      // Handle TOTP MFA case
    case AuthSignInStep.confirmSignInWithSmsMfaCode:
      // Handle SMS MFA case
    case AuthSignInStep.confirmSignInWithNewPassword:
      // Handle new password case
    case AuthSignInStep.confirmSignInWithCustomChallenge:
      // Handle custom challenge case
    case AuthSignInStep.resetPassword:
      // Handle reset password case
    case AuthSignInStep.confirmSignUp:
      // Handle confirm sign up case
    case AuthSignInStep.done:
      safePrint('Sign in is complete');
  }
}

Possible fixes Updating return types on the signInWithCognito function to Future<void> or return a success or fail boolean.

ShatilKhan commented 1 year ago

Can I take a look at this?