forgotPassword static method

Future<void> forgotPassword(
  1. String email, {
  2. MBManager? manager,
})

Password reset, an email is sent to the user with the instructions to re-set the password.

  • Parameters:
    • email: The email of the user.
    • manager: An optional MBManager used to make calls instead of MBManager.shared.
  • Returns a Future that completes when the api is called with success.

Implementation

static Future<void> forgotPassword(
  String email, {
  MBManager? manager,
}) async {
  MBManager mbManager = manager ?? MBManager.shared;

  String apiName = 'api/forgot-password';

  var uri = Uri.https(mbManager.endpoint, apiName);

  Map<String, String> apiParameters = {};
  apiParameters['email'] = email;
  apiParameters.addAll(await mbManager.defaultParameters());

  var requestBody = json.encode(apiParameters);

  Map<String, String> headers =
      await mbManager.headers(contentTypeJson: true);

  http.Response response = await http.post(
    uri,
    headers: headers,
    body: requestBody,
  );

  MBManager.checkResponse(response.body, checkBody: false);
}