resetPassword method

Future<void> resetPassword({
  1. String? email,
  2. required String challengeToken,
  3. required String password,
  4. bool? doNotNotify,
})

Resets the user's password using a challenge token.

This method completes the password reset process by setting a new password for the user. It requires a valid challenge token obtained from the forgotPassword method.

Parameters

  • email: The email address of the user
  • challengeToken: The challenge token from the password reset email
  • password: The new password to set for the user
  • doNotNotify: If true, suppresses sending a confirmation email

Throws

  • HttpException if there's a network error
  • CalljmpException if the challenge token is invalid or expired

Example

await calljmp.users.auth.email.resetPassword(
  email: 'user@example.com',
  challengeToken: 'token-from-email',
  password: 'new_secure_password',
);

print('Password reset successfully');

Implementation

Future<void> resetPassword({
  String? email,
  required String challengeToken,
  required String password,
  bool? doNotNotify,
}) => http
    .request("${_config.serviceUrl}/users/auth/email/password")
    .use(http.context(_config))
    .use(http.access())
    .put({
      "email": email,
      "token": challengeToken,
      "password": password,
      "doNotNotify": doNotNotify,
    })
    .json();