算法评测平台前端。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.5 KiB

7 years ago
<% this.title = '重设密码'; %>
<% this.noPreserveUrl = true; %>
<% include header %>
7 years ago
<div class="ui message" id="msgBox" hidden>
<p id="msgContent"></p>
</div>
<div class="ui middle aligned center aligned grid">
<div class="row">
<div class="column" style="max-width: 450px">
<h2 class="ui image header">
<div class="content">
重设密码
</div>
</h2>
7 years ago
<form class="ui large form" id="resetForm">
<div class="ui existing segment">
7 years ago
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input type="password" placeholder="密码" id="password1">
</div>
7 years ago
</div>
<div class="field">
<div class="ui left icon input">
<i class="undo icon"></i>
<input type="password" placeholder="确认密码" id="password2">
</div>
</div>
7 years ago
<button type="submit" class="ui fluid large submit button" id="resetPassword">重设</div>
</div>
</form>
</div>
</div>
</div>
<script src="<%- lib('blueimp-md5/2.10.0/js/md5.min.js') %>"></script>
<script type="text/javascript">
function showMessage(mclass, content) {
$("#msgBox").addClass(mclass);
$("#msgContent").text(content);
$("#msgBox").show();
}
function submitForm() {
if ($("#password1").val() != $("#password2").val()) {
showMessage("两次输入的密码不一致");
return;
}
password = md5($("#password1").val() + "syzoj2_xxx");
$("#resetPassword").addClass("loading");
$.ajax({
url: "/api/reset_password",
type: 'POST',
data: {
"token": <%- JSON.stringify(token) %>,
"password": password
},
async: true,
success: function(data) {
error_code = data.error_code;
switch (error_code) {
case 1:
showMessage("positive", "密码重置成功。");
7 years ago
break;
default:
7 years ago
showMessage("error", "未知错误 " + error_code);
break;
}
$("#resetPassword").removeClass("loading");
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest.responseText);
}
});
}
$(document).ready(function() {
7 years ago
$("#resetForm").submit(function(event) {
submitForm();
7 years ago
event.preventDefault();
});
});
</script>