Security PasswordReset在WebMatrix中不起作用
我正在使用WebMatrix中现有的密码重置表单。我没有改变模块中的任何内容,但它不起作用。当我点击“你忘记密码了吗?”链接时,它会将我带到前面提到的密码表单。输入电子邮件地址并单击“发送说明”后,它将转到我的电子邮件。但是,当我点击它提供的链接时,我立即进入密码重置屏幕,但屏幕顶部说,“无法重置密码。请更正错误,然后重试。”尽管如此,我还是尝试重置密码,但什么都没有发生 以下是密码重置代码:Security PasswordReset在WebMatrix中不起作用,security,razor,webmatrix,webmail,webmatrix-3,Security,Razor,Webmatrix,Webmail,Webmatrix 3,我正在使用WebMatrix中现有的密码重置表单。我没有改变模块中的任何内容,但它不起作用。当我点击“你忘记密码了吗?”链接时,它会将我带到前面提到的密码表单。输入电子邮件地址并单击“发送说明”后,它将转到我的电子邮件。但是,当我点击它提供的链接时,我立即进入密码重置屏幕,但屏幕顶部说,“无法重置密码。请更正错误,然后重试。”尽管如此,我还是尝试重置密码,但什么都没有发生 以下是密码重置代码: @* Remove this section if you are using bundling *@
@* Remove this section if you are using bundling *@
@section Scripts {
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
}
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "Password Reset";
var passwordResetToken = Request.Form["resetToken"] ?? Request.QueryString["resetToken"];
bool tokenExpired = false;
bool isSuccess = false;
// Setup validation
Validation.RequireField("newPassword", "The new password field is required.");
Validation.Add("confirmPassword",
Validator.EqualsTo("newPassword", "The new password and confirmation password do not match."));
Validation.RequireField("passwordResetToken", "The password reset token field is required.");
Validation.Add("newPassword",
Validator.StringLength(
maxLength: Int32.MaxValue,
minLength: 6,
errorMessage: "New password must be at least 6 characters"));
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", "The password reset token is invalid.");
tokenExpired = true;
}
}
}
<hgroup class="title">
<h1>@Page.Title.</h1>
<h2>Use the form below to reset your password.</h2>
</hgroup>
@if (!WebMail.SmtpServer.IsEmpty()) {
if (!Validation.IsValid()) {
<p class="validation-summary-errors">
@if (tokenExpired) {
<text>The password reset token is incorrect or may be expired. Visit the <a href="~/Account/ForgotPassword">forgot password page</a>
to generate a new one.</text>
} else {
<text>Could not reset password. Please correct the errors and try again.</text>
}
</p>
}
if (isSuccess) {
<p class="message-success">
Password changed! Click <a href="~/Account/Login" title="Log in">here</a> to log in.
</p>
}
<form method="post">
@AntiForgery.GetHtml()
<fieldset>
<legend>Password Change Form</legend>
<ol>
<li class="new-password">
<label for="newPassword" @if (!ModelState.IsValidField("newPassword")) {<text>class="error-label"</text>}>New password</label>
<input type="password" id="newPassword" name="newPassword" disabled="@isSuccess" @Validation.For("newPassword") />
@Html.ValidationMessage("newPassword")
</li>
<li class="confirm-password">
<label for="confirmPassword" @if (!ModelState.IsValidField("confirmPassword")) {<text>class="error-label"</text>}>Confirm password</label>
<input type="password" id="confirmPassword" name="confirmPassword" disabled="@isSuccess" @Validation.For("confirmPassword") />
@Html.ValidationMessage("confirmPassword")
</li>
<li class="reset-token">
<label for="resetToken" @if (!ModelState.IsValidField("resetToken")) {<text>class="error-label"</text>}>Password reset token</label>
<input type="text" id="resetToken" name="resetToken" value="@passwordResetToken" disabled="@isSuccess" @Validation.For("resetToken") />
@Html.ValidationMessage("resetToken")
</li>
</ol>
<input type="submit" value="Reset password" disabled="@isSuccess"/>
</fieldset>
</form>
} else {
<p class="message-info">
Password recovery is disabled for this website because the SMTP server is
not configured correctly. Please contact the owner of this site to reset
your password.
</p>
}
更改用户对象中的常量。从中删除所需的属性。也。我建议您编写自己的基本身份验证。更改用户对象中的常量。从中删除所需的属性。也。我建议您编写自己的基本身份验证。这是什么意思?我没听你的。你好,对不起,我没多少时间了。WebMatrix是一个轻量级的身份验证框架,在使用时具有一定的稳定性。其中之一是视图中的chtml属性。在那里,您可以看到验证规则删除它们,您的错误将被释放。我也和WebMatrix合作了很长一段时间,现在有很多类似的一致性,我已经写了我自己的框架,我建议你这样做。这是什么意思?我没听你的。你好,对不起,我没多少时间了。WebMatrix是一个轻量级的身份验证框架,在使用时具有一定的稳定性。其中之一是视图中的chtml属性。在那里,您可以看到验证规则删除它们,您的错误将被释放。我也和WebMatrix合作了很长一段时间,现在有很多类似的一致性,我已经写了我自己的框架,我建议你这样做。顺致敬意,
OAuthWebSecurity.RegisterGoogleClient();
WebMail.SmtpServer = "smtp.gmail.com";
WebMail.EnableSsl = true;
WebMail.SmtpPort = 587;
WebMail.UserName = "mark.anthnony@yahoo.com";
WebMail.Password = "September";
WebMail.From = "mark.anthony@yahoo.com";