updatePassword method

Future<Response?> updatePassword(
  1. String emailOrPhone,
  2. String updatedPassword
)

This function updates the password of a user with the given email address or phone number. Example:

db.bagelUsersRequest.updatePassword(
    "test@gmail.com",
    "NewPasswordThatShouldBeStrong"
)
  • [emailOrPhone]: The email/phone of the user you want to update the password for.
  • [updatedPassword]: The new password that you want to set for the user.

Implementation

Future<Response?> updatePassword(
    String emailOrPhone, String updatedPassword) async {
  String url = '$authEndpoint/user/updatePassword';
  Map body = {"password": updatedPassword};
  String _emailOrPhone = emailOrPhone.trim().toLowerCase();

  if (_emailOrPhone.contains('@'))
    body["email"] = _emailOrPhone;
  else
    body["phone"] = _emailOrPhone;

  try {
    final res = await dio.post(url, data: body);
    return res;
  } catch (e) {
    if (e is DioException) throw (e.response.toString());
    return null;
  }
}