Advertisement
Guest User

Untitled

a guest
May 4th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. [AllowAnonymous]
  2. public async Task<ActionResult> ResetPassword()
  3. {
  4. var provider = new DpapiDataProtectionProvider("AppName");
  5. var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>());
  6. userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(provider.Create("EmailConfirmation"));
  7. string userId = Request.QueryString["UserId"];
  8. string code = Request.QueryString["code"];
  9. var user = await UserManager.FindByIdAsync(userId);
  10. //if (!(await UserManager.ConfirmEmailAsync(userId, code)).Succeeded)
  11. ApplicationDbContext context = new ApplicationDbContext();
  12. UserStore<ApplicationUser> store = new UserStore<ApplicationUser>(context);
  13. if (!await userManager.UserTokenProvider.ValidateAsync("EmailConfirmation", code, new UserManager<ApplicationUser>(store) , user))
  14. {
  15. return RedirectToAction("Message", "Home", new { status = false, message = "Invalid token, please retry." });
  16. }
  17. return View("ResetPassword", new ResetPasswordModel { UserId = userId, Token = code });
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement