updatePasswordWithToken method
Updates (resets) the password to the chosen password by passing the resetToken
.
The final step in the resetting of a forgotten password.
Implementation
@override
Future<RequestResponse<UpdatePasswordResponse?>> updatePasswordWithToken({
String? resetToken,
String? newPassword,
}) async {
await getFrappe().checkAppInstalled(features: ['updatePasswordWithToken']);
assert(resetToken != null && resetToken.isNotEmpty,
"Reset Token can't be empty");
assert(newPassword != null && newPassword.isNotEmpty,
"Password can't be empty");
final response = await Request.initiateRequest(
url: config.hostUrl,
method: HttpMethod.POST,
contentType: ContentTypeLiterals.APPLICATION_JSON,
data: <String, dynamic>{
'cmd': 'renovation_core.utils.forgot_pwd.update_password',
'reset_token': resetToken,
'new_password': newPassword
});
if (response.isSuccess) {
final updateResponse =
UpdatePasswordResponse.fromJson(response.data!.message);
if (updateResponse.updated!) {
return RequestResponse.success(updateResponse,
rawResponse: response.rawResponse);
} else {
return RequestResponse.fail(
ErrorDetail(
title: updateResponse.reason,
info: Information(httpCode: 400),
),
)..data = updateResponse;
}
}
return RequestResponse.fail(response.error!);
}