本文整理汇总了C#中UserManager.GeneratePasswordResetToken方法的典型用法代码示例。如果您正苦于以下问题:C# UserManager.GeneratePasswordResetToken方法的具体用法?C# UserManager.GeneratePasswordResetToken怎么用?C# UserManager.GeneratePasswordResetToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager.GeneratePasswordResetToken方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForgotPassword
public ActionResult ForgotPassword(string email)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindByEmail(email);
CreateTokenProvider(manager, PASSWORD_RESET);
var code = manager.GeneratePasswordResetToken(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Home",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
ViewBag.FakeEmailMessage = "Please reset your password by clicking <a href=\""
+ callbackUrl + "\">here</a>";
return View();
}
示例2: ForgotPassword
public ActionResult ForgotPassword(string email, RegisteredUser userRecovery)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindByEmail(email);
CreateTokenProvider(manager, PASSWORD_RESET);
var code = manager.GeneratePasswordResetToken(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Accounts",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
var body = "Please reset your password by clicking <a href=\""
+ callbackUrl + "\">here</a>";
MailHelper mailer = new MailHelper();
string response = mailer.EmailFromArvixe(
new RegisteredUser(userRecovery.Email = email, userRecovery.Subject = "Password Recovery Email", userRecovery.Body = body));
return View("PasswordEmail");
}
示例3: ForgotPassword
public ActionResult ForgotPassword(string email)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindByEmail(email);
CreateTokenProvider(manager, PASSWORD_RESET);
if (user != null)
{
var code = manager.GeneratePasswordResetToken(user.Id);
string callbackUrl = Url.Action("ResetPassword", "Home",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
string emailMessage = "Please reset your password by clicking <a href=\""
+ callbackUrl + "\">here</a>";
string response = new MailHelper().EmailFromArvixe(new ViewModels.Message(email, emailMessage));
ViewBag.FakeEmailMessage = "Email successfully sent. Please check your email to reset your password";
return View();
}
ViewBag.Error = "There wasn't an account for that email";
return View();
}
示例4: ForgotPassword
public ActionResult ForgotPassword(string email)
{
//ensures valid input
if (ModelState.IsValid)
{
CaptchaHelper captchaHelper = new CaptchaHelper();
string captchaResponse = captchaHelper.CheckRecaptcha();
ViewBag.CaptchaResponse = captchaResponse;
//creates token to be sent to mail helper to allow password reset through email
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindByEmail(email);
CreateToken ct = new CreateToken();
CreateTokenProvider(manager, PASSWORD_RESET);
var code = manager.GeneratePasswordResetToken(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Home",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
//send callbackUrl to email helper
MailHelper mailer = new MailHelper();
string message = "Please reset your password by clicking <a href=\""
+ callbackUrl + "\">here</a>";
string subject = "Please reset your password";
try
{
mailer.EmailFromArvixe(message, user.Email, subject);
ViewBag.FakeEmailMessage =
"You have been sent an email to finish reseting your password";
}
catch (System.Exception ex)
{
ViewBag.FakeEmailMessage = ex.Message;
}
}
return View();
}
示例5: ForgotPassword
public ActionResult ForgotPassword(string email)
{
CaptchaHelper captchaHelper = new CaptchaHelper();
string captchaResponse = captchaHelper.CheckRecaptcha();
ViewBag.CaptchaResponse = captchaResponse;
if (captchaResponse == VALID_CAPTCHA)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindByEmail(email);
CreateTokenProvider(manager, PASSWORD_RESET);
var code = manager.GeneratePasswordResetToken(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Home",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
var emailMsg = "<h3>Please reset your password by clicking</h3> <a href=\""
+ callbackUrl + "\">This Link</a>";
MailHelper mailer = new MailHelper();
string response = mailer.EmailFromArvixe(new RegisteredUser { Email = user.Email, UserName = user.UserName }, emailMsg);
ViewBag.Response = response;
TempData["response"] = response;
return RedirectToAction("Index", "Home");
}
return View();
}
示例6: EmailConfirmationToken
public void EmailConfirmationToken()
{
var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(this._session));
userManager.UserTokenProvider = new EmailTokenProvider<ApplicationUser, string>() { BodyFormat = "xxxx {0}", Subject = "Reset password" };
userManager.Create(new ApplicationUser() { UserName = "test", Email = "[email protected]", EmailConfirmed = false }, "Welcome");
var x = userManager.FindByEmail("[email protected]");
string token = userManager.GeneratePasswordResetToken(x.Id);
userManager.ResetPassword(x.Id, token, "Welcome!");
}
示例7: ForgotPassword
public ActionResult ForgotPassword(string email)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindByEmail(email);
CreateTokenProvider(manager, PASSWORD_RESET);
var code = manager.GeneratePasswordResetToken(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Account",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
string link = "Please reset your password by clicking <a href=\""
+ callbackUrl + "\">here</a>";
MailHelper mailer = new MailHelper();
string response = mailer.EmailFromArvixe(
new RegisteredUser(email, PASSWORD_RESET, link));
if (response != "Failure sending mail.")
{
ViewBag.Success = response;
}
else {
ViewBag.Failure = response;
}
return View();
}
示例8: ForgotPassword
public ActionResult ForgotPassword(string email)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindByEmail(email);
if (user == null)
{
ViewBag.Message = "Email not found. Please double-check and try again.";
return View();
}
CreateTokenProvider(manager, PASSWORD_RESET);
var code = manager.GeneratePasswordResetToken(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Home",
new { userId = user.Id, code = code },
protocol: Request.Url.Scheme);
string emailBody = "Please reset your password by clicking <a href=\""
+ callbackUrl + "\">here</a>";
MailHelper mailer = new MailHelper();
string Subject = "Confirm password reset";
string response = mailer.EmailFromArvixe(
new Message(user.Email, Subject, emailBody));
if (response.IndexOf("Success") >= 0)
{
ViewBag.Message = "A confirm email has been sent. Please check your your email.";
ViewBag.Email = user.Email;
}
else
{
ViewBag.Message = response;
}
return View();
}