增加修改密码的验证码
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, csrfTokenHeader) {
|
||||
|
||||
function refresh_captcha(){
|
||||
this.src = "/captcha/?" + Math.random();
|
||||
$("#captcha")[0].value = "";
|
||||
}
|
||||
$("#captcha-img").click(function(){
|
||||
refresh_captcha();
|
||||
});
|
||||
|
||||
$('form').validator().on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var newPassword = $("#new_password ").val();
|
||||
var password = $("#password").val();
|
||||
var captcha = $("#captcha").val();
|
||||
$.ajax({
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/change_password/",
|
||||
data: {new_password: newPassword, old_password: password},
|
||||
data: {new_password: newPassword, old_password: password, captcha: captcha},
|
||||
dataType: "json",
|
||||
method: "post",
|
||||
success: function (data) {
|
||||
@@ -15,6 +24,7 @@ require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, c
|
||||
window.location.href = "/login/";
|
||||
}
|
||||
else {
|
||||
refresh_captcha();
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user