本文整理汇总了C#中IEmailService.SendRequestResetPassword方法的典型用法代码示例。如果您正苦于以下问题:C# IEmailService.SendRequestResetPassword方法的具体用法?C# IEmailService.SendRequestResetPassword怎么用?C# IEmailService.SendRequestResetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEmailService
的用法示例。
在下文中一共展示了IEmailService.SendRequestResetPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccountModule
//.........这里部分代码省略.........
if (!Principal.Identity.IsAuthenticated &&
!applicationSettings.AllowUserResetPassword ||
string.IsNullOrWhiteSpace(applicationSettings.EmailSender))
{
return HttpStatusCode.NotFound;
}
string username = Request.Form.username;
if (String.IsNullOrEmpty(username))
{
this.AddValidationError("username", LanguageResources.Authentication_NameRequired);
}
try
{
if (ModelValidationResult.IsValid)
{
ChatUser user = repository.GetUserByName(username);
if (user == null)
{
this.AddValidationError("username", String.Format(LanguageResources.Account_NoMatchingUser, username));
}
else if (String.IsNullOrWhiteSpace(user.Email))
{
this.AddValidationError("username", String.Format(LanguageResources.Account_NoEmailForUser, username));
}
else
{
membershipService.RequestResetPassword(user, applicationSettings.RequestResetPasswordValidThroughInHours);
repository.CommitChanges();
emailService.SendRequestResetPassword(user, this.Request.Url.SiteBase + "/account/resetpassword/");
return View["requestresetpasswordsuccess", username];
}
}
}
catch (Exception ex)
{
this.AddValidationError("_FORM", ex.Message);
}
return View["requestresetpassword"];
};
Get["/resetpassword/{id}"] = parameters =>
{
if (!applicationSettings.AllowUserResetPassword ||
string.IsNullOrWhiteSpace(applicationSettings.EmailSender))
{
return HttpStatusCode.NotFound;
}
string resetPasswordToken = parameters.id;
string userName = membershipService.GetUserNameFromToken(resetPasswordToken);
// Is the token not valid, maybe some character change?
if (userName == null)
{
return View["resetpassworderror", LanguageResources.Account_ResetInvalidToken];
}
else
{
ChatUser user = repository.GetUserByRequestResetPasswordId(userName, resetPasswordToken);