2018-06-09 18:07:53 +08:00
|
|
|
(function (global, document) {
|
2018-06-24 10:01:21 +08:00
|
|
|
"use strict";
|
2018-06-09 18:07:53 +08:00
|
|
|
|
2019-03-03 03:37:35 +08:00
|
|
|
global.resetPassword = function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
2018-06-24 10:01:21 +08:00
|
|
|
var allOk = global.unfilledMark(["#password", "#password2"], function(el) {
|
2018-06-09 18:07:53 +08:00
|
|
|
el.css("border-bottom", "1px solid red");
|
|
|
|
});
|
|
|
|
|
2018-06-24 10:01:21 +08:00
|
|
|
if (!allOk) {
|
2018-06-09 18:07:53 +08:00
|
|
|
global.textSet("#err", "Please make sure all fields are filled.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-06-24 10:01:21 +08:00
|
|
|
if ($("#password").val() !== $("#password2").val()) {
|
2018-06-09 18:07:53 +08:00
|
|
|
global.textSet("#err", "The two passwords do not match.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var json = {
|
2019-01-24 06:48:39 +08:00
|
|
|
"resetHex": global.paramGet("hex"),
|
2018-06-09 18:07:53 +08:00
|
|
|
"password": $("#password").val(),
|
|
|
|
};
|
|
|
|
|
|
|
|
global.buttonDisable("#reset-button");
|
2019-06-06 16:27:42 +08:00
|
|
|
global.post(global.origin + "/api/reset", json, function(resp) {
|
2018-06-09 18:07:53 +08:00
|
|
|
global.buttonEnable("#reset-button");
|
|
|
|
|
|
|
|
global.textSet("#err", "");
|
|
|
|
if (!resp.success) {
|
|
|
|
global.textSet("#err", resp.message);
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2019-06-06 16:27:42 +08:00
|
|
|
if (resp.entity === "owner") {
|
|
|
|
document.location = global.origin + "/login?changed=true";
|
|
|
|
} else {
|
|
|
|
$("#msg").html("Your password has been reset. You may close this window and try logging in again.");
|
|
|
|
}
|
2018-06-09 18:07:53 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-12-20 13:48:43 +08:00
|
|
|
} (window.commento, document));
|