抱歉,最近控制台的改动导致这里路由有点问题,我们会尽快修复。
我这里先暂时把重设密码页面的模板文件贴出来,您可以复制后修改:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>LeanCloud</title>
<link href="https://lc-avoscloud.cn-n1.lcfile.com/statics/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h3>重置密码</h3>
<hr>
<form class="form-horizontal form login-form" name="resetform" id="reset-form">
<!-- <legend>重置密码</legend> -->
<div class="alert" style="display:none" id="error">
<button type="button" class="close" data-dismiss="alert">×</button>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputEmail" id="newPass">新密码</label>
<div class="col-sm-4">
<input type="password" id="inputEmail" class="form-control" name="password" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputPassword" id="confirmPass">重新输入</label>
<div class="col-sm-4">
<input type="password" id="inputPassword" class="form-control" name="password1" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<button type="button" class="btn btn-default" id="reset">重置</button>
</div>
</div>
</form>
</div><!--end container-->
<script src="https://lc-avoscloud.cn-n1.lcfile.com/statics/jquery.min.js"></script>
<script src="https://lc-avoscloud.cn-n1.lcfile.com/statics/jquery.jsonp.js"></script>
<script type="text/javascript">
// naive mimic of polyglot.js
function Polyglot(options) {
this.phrases = options.phrases;
}
Polyglot.prototype.t = function (key) {
return this.phrases[key];
}
// i18n
var zhPhrases = {
resetPass: "重置密码",
newPass: "新密码",
confirmPass: "重新输入",
reset: "重置",
passwordMismatch: "两次输入不一致",
resetSucc:
"重置密码成功",
tokenInvalid: "Token 已过期或无效",
serverError: "服务器发生错误",
};
var enPhrases = {
resetPass: "Reset Password",
newPass: "New password",
confirmPass: "Confirm password",
reset: "Reset",
passwordMismatch: "Your password and confirmation password do not match.",
resetSucc:
"Your password has been reset.",
tokenInvalid: "Token is expired or invalid.",
serverError: "A server error occurred.",
};
var i18nPhrases =
window.navigator.language.slice(0, 2) === "zh" ? zhPhrases : enPhrases;
var polyglot = new Polyglot({ phrases: i18nPhrases });
$("h3").text(polyglot.t("resetPass"));
$("#newPass").text(polyglot.t("newPass"));
$("#confirmPass").text(polyglot.t("confirmPass"));
$("#reset").text(polyglot.t("reset"));
//获得token
var token = location.search.match(/token=(\w*)/);
if(token&&token[1]){
token = token[1];
}
$(function(){
$("#reset").click(function(){
var p = $("[name=password]");
var p1 = $("[name=password1]");
if(p.val()!=p1.val()){
$("#error").show();
$("#error").text(polyglot.t("passwordMismatch"));
}
if(p.val()&&p1.val()&&p.val()==p1.val()){
$.jsonp({
// CHANGE THE URL BELOW.
url:"https://api.example.com/1.1/resetPassword/"+token, // Replace api.example.com with your own custom api domain.
data:{"password":p.val()},
callbackParameter: "callback",
cache: false,
success:function(result){
$("#error").show(); // error is used for both success and failure message.
if(result.error){
if (result.error.startsWith("Token")) {
$("#error").text(polyglot.t("tokenInvalid"));
} else {
$("#error").text(result.error);
}
}else{
$("#error").html(polyglot.t("resetSucc"));
}
},
error:function(result,text){
$("#error").text(polyglot.t("serverError"));
}
});
}
});
});
</script>
</body>
</html>
另外邮箱验证页面的模板您可能也会用到,我这里也贴出来:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>LeanCloud</title>
<link href="https://lc-avoscloud.cn-n1.lcfile.com/statics/bootstrap.min.css" rel="stylesheet">
<style>
h3 {
text-align: center;
margin-top: 50px;
font-weight: normal;
}
</style>
</head>
<body>
<div class="container">
<h3 id="tip" style="display:none"></h3>
<!-- <h3 id="tip">Test</h3> -->
</div><!--end container-->
<script src="https://lc-avoscloud.cn-n1.lcfile.com/statics/jquery.min.js"></script>
<script src="https://lc-avoscloud.cn-n1.lcfile.com/statics/jquery.jsonp.js"></script>
<script type="text/javascript">
// naive mimic of polyglot.js
function Polyglot(options) {
this.phrases = options.phrases;
}
Polyglot.prototype.t = function (key) {
return this.phrases[key];
}
// i18n
var zhPhrases = {
"verificated": "邮箱验证成功",
"tokenInvalid": "Token 已过期或无效",
"serverError": "服务器发生错误",
}
var enPhrases = {
"verificated": "Your email address is verified.",
"tokenInvalid": "Token is expired or invalid.",
"serverError": "A server error occurred.",
}
var i18nPhrases = window.navigator.language.slice(0, 2) === "zh" ? zhPhrases : enPhrases;
var polyglot = new Polyglot({phrases: i18nPhrases });
// CHANGE THE URL BELOW.
var url = "https://api.example.com/1.1/verifyEmail/"; // Replace api.example.com with your own custom api domain.
var tip_success = polyglot.t("verificated");
function getParam() {
var prmstr = window.location.search.substr(1);
var prmarr = prmstr.split("&");
var params = {};
for (var i = 0; i < prmarr.length; i++) {
var tmparr = prmarr[i].split("=");
params[tmparr[0]] = tmparr[1];
}
return params;
}
var token = location.search.match(/token=(\w*)/);
if(token&&token[1]){
token = token[1];
}
function verify(){
if(!token){
return;
}
$.jsonp({
url:url+token,
callbackParameter: "callback",
cache: false,
success:function(result){
$("#tip").show();
if (result.error) {
if (result.error.startsWith("Token")) {
$("#tip").text(polyglot.t("tokenInvalid"));
} else {
$("#tip").text(result.error);
}
} else {
$("#tip").html(tip_success);
}
},
error:function(result,text){
$("#tip").text(polyglot.t("serverError"));
}
});
}
$(function(){
verify();
})
</script>
</body>
</html>