Advertisement
Guest User

Untitled

a guest
Jan 31st, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. [HttpPost]
  2. public ActionResult MyAction(MyViewModel model, string password)
  3.  
  4. var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
  5. var verifyPassword = UserManager.PasswordHasher.VerifyHashedPassword(user.PasswordHash, password);
  6. if (verifyPassword == PasswordVerificationResult.Failed)
  7. {
  8. ModelState.AddModelError("", "Password incorrect.");
  9. // If password is incorrect, ModelState will be invalid now
  10. }
  11.  
  12. if (ModelState.IsValid)
  13. {
  14. // save posted data
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement