verifyPasswordResetOTP method
Future<RequestResponse<VerifyResetOTPResponse?> >
verifyPasswordResetOTP({
- RESET_ID_TYPE? idType,
- String? id,
- OTP_MEDIUM? medium,
- String? mediumId,
- String? otp,
override
Verifies the otp
sent through generatePasswordResetOTP.
This is the second step for resetting a forgotten password.
Implementation
@override
Future<RequestResponse<VerifyResetOTPResponse?>> verifyPasswordResetOTP({
RESET_ID_TYPE? idType,
String? id,
OTP_MEDIUM? medium,
String? mediumId,
String? otp,
}) async {
await getFrappe().checkAppInstalled(features: ['verifyPasswordResetOTP']);
assert(id != null && id.isNotEmpty, "ID can't be empty");
assert(idType != null, "ID type can't be null");
assert(mediumId != null && mediumId.isNotEmpty, "Medium ID can't be empty");
assert(medium != null, "Medium can't be null");
assert(otp != null && otp.isNotEmpty, "OTP can't be empty");
final idTypeAsString = EnumToString.convertToString(idType);
final mediumAsString = EnumToString.convertToString(medium);
final response = await Request.initiateRequest(
url: config.hostUrl,
method: HttpMethod.POST,
contentType: ContentTypeLiterals.APPLICATION_JSON,
data: <String, dynamic>{
'cmd': 'renovation_core.utils.forgot_pwd.verify_otp',
'id_type': idTypeAsString,
'id': id,
'medium': mediumAsString,
'medium_id': mediumId,
'otp': otp
});
if (response.isSuccess) {
final otpResponse =
VerifyResetOTPResponse.fromJson(response.data!.message);
if (otpResponse.verified!) {
return RequestResponse.success(otpResponse,
rawResponse: response.rawResponse);
} else {
return RequestResponse.fail(
ErrorDetail(
title: otpResponse.reason,
info: Information(httpCode: 400),
),
)..data = otpResponse;
}
}
return RequestResponse.fail(response.error!);
}