I tried various ways as per my knowledge:
updatePassword(dataForUpdate).then((result) => {
if (result && result.status == 200) {
swal({
title: "Success",
text: "Password Updated Successfully",
icon: "success",
button: "Ok",
}).then(() => {
window.location.reload();
});
} else {
swal({
icon: "error",
title: "Update Password",
text: "Incorrect Details",
button: "Continue",
// currentPassword: "",
// newPassword: "",
// confirmpassword: "",
}).then(() => {
window.location.reload(); // instead of reloading tab, I want to clear input fields so I can give input again till satified condtions
// window.location.href = "/company/profile/";
// if (values.currentPassword !== user.password) {
// errors.currentPassword = "Wrong Password";
// values.currentPassword = "";
// setFieldValue("currentPassword", "");
// setFieldValue("newPassword", "");
// setFieldValue("confirmpassword", "");
// }
});
}
});
I also tried to validate :
else if (values.currentPassword !== user.password) {
errors.currentPassword = "Wrong Password";
values.currentPassword = "";
}
But it always gives 'Wrong Password' text even for correct one and not getting cleared input fields.
I tried to console it. Why it is printing on console for every digit that we entered ? Also, user password is encrypted, then ways to compare them ? See image:
Can you help me, how to clear/reset input fields of updating password popup if current password is not matching from user's current password.