forgotPassword method

Future<({String challengeToken})> forgotPassword({
  1. String? email,
  2. bool? doNotNotify,
})

Initiates password reset process.

This method starts the password reset flow by sending a password reset email to the user. The email will contain a challenge token that can be used to actually reset the password using the resetPassword method.

Parameters

  • email: The email address of the user requesting password reset
  • doNotNotify: If true, suppresses sending the password reset email

Returns

A Future that resolves to a record containing:

  • challengeToken: Token to use for resetting the password

Throws

  • HttpException if there's a network error
  • CalljmpException if the email is not found or invalid

Example

final reset = await calljmp.users.auth.email.forgotPassword(
  email: 'user@example.com',
);

// User will receive an email with the challenge token
print('Password reset initiated: ${reset.challengeToken}');

Implementation

Future<({String challengeToken})> forgotPassword({
  String? email,
  bool? doNotNotify,
}) => http
    .request("${_config.serviceUrl}/users/auth/email/password")
    .use(http.context(_config))
    .use(http.access())
    .post({"email": email, "doNotNotify": doNotNotify})
    .json((json) => (challengeToken: json["challengeToken"]));