resetPassword method

Future<void> resetPassword(
  1. String username
)

Initiates a password reset flow for the given username

Implementation

Future<void> resetPassword(
  String username,
) async {
  emit(state.startLoading(resetPasswordLoading));

  try {
    final verificationCode = await provider.resetPassword(username);
    emit(state.copyWith(
      awaitingVerification: verificationCode,
    ));
  } on ResetPasswordLimitException catch (error, stackTrace) {
    emit(state.addMessage(
      Message.error(_localizations.resetPasswordLimit),
      error,
      stackTrace,
    ));
  } on ResetPasswordException catch (error, stackTrace) {
    emit(state.addMessage(
      Message.error(
        _localizations.resetPasswordError(error.message),
      ),
      error,
      stackTrace,
    ));
  } finally {
    emit(state.endLoading(resetPasswordLoading));
  }
}