Advertisement
Guest User

Untitled

a guest
Feb 15th, 2017
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. | Email | NormalizedEmail | NormalizedUserName | UserName |
  2. +-----------------+--------------------+---------------------+-----------------+
  3. | test@here.com | TEST@HERE.COM | TEST@HERE.COM | test@here.com |
  4.  
  5. public async Task<IActionResult> ResetPassword(ResetPasswordViewModel model)
  6. {
  7. if (!ModelState.IsValid)
  8. {
  9. return View(model);
  10. }
  11. var user = await _userManager.FindByEmailAsync(model.Email);
  12. if (user == null)
  13. {
  14. // Don't reveal that the user does not exist
  15. return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
  16. }
  17. var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password);
  18. if (result.Succeeded)
  19. {
  20. return RedirectToAction(nameof(AccountController.ResetPasswordConfirmation), "Account");
  21. }
  22. AddErrors(result);
  23. return View();
  24. }
  25.  
  26. | Email | NormalizedEmail | NormalizedUserName | UserName |
  27. +-----------------+--------------------+---------------------+-----------------+
  28. | test@here.com | TEST@HERE.COM | TEST | test@here.com |
  29.  
  30. public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null)
  31. {
  32. ViewData["ReturnUrl"] = returnUrl;
  33. if (ModelState.IsValid)
  34. {
  35. // This doesn't count login failures towards account lockout
  36. // To enable password failures to trigger account lockout, set lockoutOnFailure: true
  37. var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
  38. if (result.Succeeded)
  39. {
  40. _logger.LogInformation(1, "User logged in.");
  41. return RedirectToLocal(returnUrl);
  42. }
  43. if (result.RequiresTwoFactor)
  44. {
  45. return RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
  46. }
  47. if (result.IsLockedOut)
  48. {
  49. _logger.LogWarning(2, "User account locked out.");
  50. return View("Lockout");
  51. }
  52. else
  53. {
  54. ModelState.AddModelError(string.Empty, "Invalid login attempt.");
  55. return View(model);
  56. }
  57. }
  58.  
  59. // If we got this far, something failed, redisplay form
  60. return View(model);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement