@* 若您在使用組合,請移除此區段 *@
@section Scripts {
}
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "密碼重設";
var passwordResetToken = Request.Form["resetToken"] ?? Request.QueryString["resetToken"];
bool tokenExpired = false;
bool isSuccess = false;
// 設定驗證
Validation.RequireField("newPassword", "新密碼欄位為必填。");
Validation.Add("confirmPassword",
Validator.EqualsTo("newPassword", "新密碼和確認密碼不相符。"));
Validation.RequireField("passwordResetToken", "密碼重設語彙基元欄位為必填。");
Validation.Add("newPassword",
Validator.StringLength(
maxLength: Int32.MaxValue,
minLength: 6,
errorMessage: "新密碼必須至少有 6 個字元"));
if (IsPost && Validation.IsValid()) {
AntiForgery.Validate();
var newPassword = Request["newPassword"];
var confirmPassword = Request["confirmPassword"];
if (WebSecurity.ResetPassword(passwordResetToken, newPassword)) {
isSuccess = true;
} else {
ModelState.AddError("passwordResetToken", "密碼重設語彙基元無效。");
tokenExpired = true;
}
}
}
@Page.Title.
使用下列表格來重設您的密碼。
@if (!WebMail.SmtpServer.IsEmpty()) {
if (!Validation.IsValid()) {
@if (tokenExpired) {