confirmResetPassword method

Future<ResetPasswordResult> confirmResetPassword({
  1. required String username,
  2. required String newPassword,
  3. required String confirmationCode,
  4. ConfirmResetPasswordOptions? options,
})

Completes the password reset process given a username, new password, and the confirmation code which was sent calling resetPassword.

username must be the same as the value used when signing in and is either an identifier chosen by the user or their email/phone number, depending on the configuration.

Optionally accepts plugin options which allow customizing provider-specific behavior, e.g. the Cognito User Pool.

For more information, see the Amplify docs.

Examples

import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
Future<void> confirmResetPassword({
  required String username,
  required String newPassword,
  required String confirmationCode,
}) async {
  try {
    final result = await Amplify.Auth.confirmResetPassword(
      username: username,
      newPassword: newPassword,
      confirmationCode: confirmationCode,
    );
    safePrint('Password reset complete: ${result.isPasswordReset}');
  } on AuthException catch (e) {
    safePrint('Error resetting password: ${e.message}');
  }
}

Implementation

Future<ResetPasswordResult> confirmResetPassword({
  required String username,
  required String newPassword,
  required String confirmationCode,
  ConfirmResetPasswordOptions? options,
}) =>
    identifyCall(
      AuthCategoryMethod.confirmResetPassword,
      () => defaultPlugin.confirmResetPassword(
        username: username,
        newPassword: newPassword,
        confirmationCode: confirmationCode,
        options: options,
      ),
    );