startPasswordReset static method

Future<void> startPasswordReset(
  1. Session session, {
  2. required String email,
  3. Transaction? transaction,
})

Requests a password reset for email.

If the email address is registered, an email with reset instructions will be send out. If the email is unknown, this method will have no effect.

Throws an EmailAccountPasswordResetRequestTooManyAttemptsException in case the client or account has been involved in too many reset attempts.

Implementation

static Future<void> startPasswordReset(
  final Session session, {
  required final String email,
  final Transaction? transaction,
}) async {
  final result = await EmailAccounts.startPasswordReset(
    session,
    email: email,
    transaction: transaction,
  );

  // The details of the operation are intentionally not given to the caller, in order to not leak the existence of accounts.
  // Clients should always show something like "check your email to proceed with the password reset".
  if (result != PasswordResetResult.passwordResetSent) {
    session.log(
      'Failed to start password reset for $email, reason: $result',
      level: LogLevel.debug,
    );
  }
}