79 lines
1.8 KiB
HTML
79 lines
1.8 KiB
HTML
{% block title %} {{_("Reset Password")}} {% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- no-sidebar -->
|
|
<div class="row" style="margin-top: 40px; margin-bottom: 20px">
|
|
<div class="col-sm-6">
|
|
<form id="reset-password">
|
|
<div class="form-group">
|
|
<input id="old_password" type="password"
|
|
class="form-control" placeholder="{{ _("Old Password") }}">
|
|
</div>
|
|
<div class="form-group">
|
|
<input id="new_password" type="password"
|
|
class="form-control" placeholder="{{ _("New Password") }}">
|
|
</div>
|
|
<div class="form-group">
|
|
<button type="submit" id="update"
|
|
class="btn btn-primary">{{_("Update")}}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
if(get_url_arg("key")) {
|
|
$("#old_password").parent().toggle(false);
|
|
}
|
|
|
|
$("#reset-password").on("submit", function() {
|
|
return false;
|
|
});
|
|
|
|
$("#new_password").on("keypress", function(e) {
|
|
if(e.which===13) $("#update").click();
|
|
})
|
|
|
|
$("#update").click(function() {
|
|
var args = {
|
|
key: get_url_arg("key") || "",
|
|
old_password: $("#old_password").val(),
|
|
new_password: $("#new_password").val()
|
|
}
|
|
|
|
if(!args.old_password && !args.key) {
|
|
frappe.msgprint("Old Password Required.");
|
|
return;
|
|
}
|
|
if(!args.new_password) {
|
|
frappe.msgprint("New Password Required.")
|
|
return;
|
|
}
|
|
|
|
frappe.call({
|
|
type: "POST",
|
|
method: "frappe.core.doctype.user.user.update_password",
|
|
btn: $("#update"),
|
|
args: args,
|
|
callback: function(r) {
|
|
$("input").val("");
|
|
if(r.message) {
|
|
frappe.msgprint(__("Password Updated"));
|
|
setTimeout(function() {
|
|
window.location.href = r.message;
|
|
}, 2000);
|
|
}
|
|
if(r.exc) {
|
|
frappe.msgprint(r.exc);
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
});
|
|
|
|
</script>
|
|
{% endblock %}
|