getPasswordResetInfo method

  1. @override
Future<RequestResponse<ResetPasswordInfo?>> getPasswordResetInfo({
  1. RESET_ID_TYPE? type,
  2. String? id,
})
override

Gets the password possible reset methods & hints about these methods.

The response is based on ResetPasswordInfo model.

The type represents the type of the id such as email or mobile. The id is the actual id such as "abc@example.com" if email.

Implementation

@override
Future<RequestResponse<ResetPasswordInfo?>> getPasswordResetInfo({
  RESET_ID_TYPE? type,
  String? id,
}) async {
  await getFrappe().checkAppInstalled(features: ['getPasswordResetInfo']);

  assert(type != null, 'Type cant be empty');
  assert(id != null && id.isNotEmpty, "ID can't be empty");
  assert(type != null, "ID type can't be null");

  final typeAsString = EnumToString.convertToString(type);

  final response = await Request.initiateRequest(
      url: config.hostUrl,
      method: HttpMethod.POST,
      contentType: ContentTypeLiterals.APPLICATION_JSON,
      data: <String, dynamic>{
        'cmd': 'renovation_core.utils.forgot_pwd.get_reset_info',
        'id_type': typeAsString,
        'id': id
      });

  if (response.isSuccess) {
    if (response.data!.message != null) {
      return RequestResponse.success(
          ResetPasswordInfo.fromJson(response.data!.message),
          rawResponse: response.rawResponse);
    }
  }
  return RequestResponse.fail(response.error!);
}