我用passwordrecovery控件,不管输入的问题答案是否正确,都会发送一封邮件到用户的邮箱里。
我用passwordrecovery控件,不管输入的问题答案是否正确,都会发送一封邮件到用户的邮箱里。
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server" MembershipProvider="AspNetAccessMembershipProvider" >
<MailDefinition BodyFileName="~/common/emailformat.txt" From="depingzhao@163.com"
IsBodyHtml="True" Subject="密码找回">
</MailDefinition>
</asp:PasswordRecovery>
我的自定义membership提供程序:
public string GetPassword(string username)
{
try
{
MembershipUser user = Membership.GetUser(username);
string question = user.PasswordQuestion;
return question;
}
catch
{
return "no users";
}
}
public override string GetPassword(string username, string answer)
{
try
{
MembershipUser user = Membership.GetUser(username);
string question = GetPassword(username);
if (answer == "00000")
{
return user.Comment;
}
else
{
return "cuowu";
}
}
catch
{
return "false";
}
}
public override string ResetPassword(string username, string answer)
{
try
{
MembershipUser user = Membership.GetUser(username);
string question = user.PasswordQuestion;
if (false)
{
return user.Comment;
}
else
{
return "daancuo";
}
}
catch
{
return "false";
}
}