How to check if user is confirmed(email/phone verified) in AWS Amplify for Flutter

Viewed 1322

Let's say in my application; I want to offer some parts of the features only for verified users. I am confused about how to check if the current user is verified or not. I checked to Amplify docs for flutter but couldn't find a proper way for it.

1 Answers

Please see this Thread: https://github.com/aws-amplify/amplify-flutter/issues/581

It says:

iOS isSignupComplete is determined by AuthSignUpResult.nextStep. The former is always false when nextStep != done.

Android isSignupComplete is marked as true once the sign up request completed successfully.

Although isSignupComplete may be inconsistent between both platforms, checking SignUpResult.nextStep should be sufficient to determine if user has completed signing up confirmation.

E.g.

SignUpResult createAccountResult = await Amplify.Auth.signUp(
  username: email.text,
  password: password.text,
  options: CognitoSignUpOptions(userAttributes: {'email': email.text}));

if (res.nextStep.signUpStep == 'CONFIRM_SIGN_UP_STEP') {
  // continue to confirm sign up step
}

if (res.nextStep.signUpStep == 'DONE') {
  // complete sign up
}

This applies to native Plattforms but should be the same by checking signUpStep in Flutter

Related