fix: update password API mapping for /update-password

This commit is contained in:
Gavin D'souza 2020-04-24 18:32:03 +05:30
parent 16e96b14f8
commit e0d9cf50df

View file

@ -9,7 +9,7 @@
<span class='indicator blue password-box'>{{ _("Reset Password") if frappe.db.get_default('company') else _("Set Password")}}</span>
</div>
<form id="reset-password">
<div class="form-group">
<div class="form-group" style="display: none;">
<input id="old_password" type="password"
class="form-control" placeholder="{{ _("Old Password") }}">
</div>
@ -32,8 +32,8 @@
<script>
frappe.ready(function() {
if(frappe.utils.get_url_arg("key")) {
$("#old_password").parent().toggle(false);
if(!frappe.utils.get_url_arg("key")) {
$("#old_password").parent().toggle();
}
if(frappe.utils.get_url_arg("password_expired")) {
@ -57,12 +57,10 @@ frappe.ready(function() {
}
if(!args.old_password && !args.key) {
frappe.msgprint("{{ _('Old Password Required.') }}");
return;
frappe.msgprint(__("Old Password Required."));
}
if(!args.new_password) {
frappe.msgprint("{{ _('New Password Required.') }}");
return;
frappe.msgprint(__("New Password Required."));
}
frappe.call({
type: "POST",
@ -71,19 +69,24 @@ frappe.ready(function() {
args: args,
statusCode: {
401: function() {
$('.page-card-head .indicator').removeClass().addClass('indicator red')
.text("{{ _('Invalid Password') }}");
$(".page-card-head .indicator").removeClass().addClass("indicator red").text(__("Invalid Password"));
},
410: function({ responseJSON }) {
const title = __("Invalid Link");
const message = responseJSON.message;
$(".page-card-head .indicator").removeClass().addClass("indicator grey").text(title);
frappe.msgprint({ title: title, message: message, clear: true });
},
200: function(r) {
$("input").val("");
strength_indicator.addClass('hidden');
strength_message.addClass('hidden');
$('.page-card-head .indicator')
.removeClass().addClass('indicator blue')
.html("{{ _('Status Updated') }}");
strength_indicator.addClass("hidden");
strength_message.addClass("hidden");
$(".page-card-head .indicator")
.removeClass().addClass("indicator blue")
.html(__("Status Updated"));
if(r.message) {
frappe.msgprint({
message: `{{ _('${r.message}') }}`,
message: __("Password Updated"),
// password is updated successfully
// clear any server message
clear: true