本文整理汇总了C#中UserManager.ResetPassword方法的典型用法代码示例。如果您正苦于以下问题:C# UserManager.ResetPassword方法的具体用法?C# UserManager.ResetPassword怎么用?C# UserManager.ResetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager.ResetPassword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetPassword
public ActionResult ResetPassword(string password, string passwordConfirm,
string passwordToken, string userID)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindById(userID);
CreateTokenProvider(manager, PASSWORD_RESET);
IdentityResult result = manager.ResetPassword(userID, passwordToken, password);
if (result.Succeeded)
ViewBag.Result = "The password has been reset.";
else
ViewBag.Result = "The password has not been reset.";
return View();
}
示例2: 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!");
}
示例3: ResetPassword
public ActionResult ResetPassword(string password, string passwordConfirm,
string passwordToken, string userID)
{
//called from email link, receives token and allows user to change password
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindById(userID);
CreateToken ct = new CreateToken();
CreateTokenProvider(manager, PASSWORD_RESET);
IdentityResult result = manager.ResetPassword(userID, passwordToken, password);
if (result.Succeeded)
ViewBag.Result = "The password has been reset.";
else
ViewBag.Result = "The password has not been reset.";
return View();
}
示例4: ResetPassword
public ActionResult ResetPassword(ResetPassword resetPassword,
string passwordToken, string userID)
{
if (ModelState.IsValid)
{
var userStore = new UserStore<IdentityUser>();
UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
var user = manager.FindById(userID);
CreateTokenProvider(manager, PASSWORD_RESET);
IdentityResult result = manager.ResetPassword(userID, passwordToken, resetPassword.Password);
if (result.Succeeded)
{
TempData["Message"] = "The password has been reset. Please login in";
return RedirectToAction("Index");
}
else {
ViewBag.Message = "The password has not been reset.";
}
}
else
{
ViewBag.Message = "Passworld reset failed. Please make sure password combine alphabet letter and numbers.";
}
return View();
}