Guest User

Untitled

a guest
Dec 9th, 2017
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. //
  2. // POST: /Account/Login
  3. [HttpPost]
  4. [AllowAnonymous]
  5. [ValidateAntiForgeryToken]
  6. public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
  7. {
  8. if (!ModelState.IsValid)
  9. {
  10. return View(model);
  11. }
  12.  
  13. // This doesn't count login failures towards account lockout
  14. // To enable password failures to trigger account lockout, change to shouldLockout: true
  15. var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
  16. switch (result)
  17. {
  18. case SignInStatus.Success:
  19. return RedirectToLocal(returnUrl);
  20. case SignInStatus.LockedOut:
  21. return View("Lockout");
  22. case SignInStatus.RequiresVerification:
  23. return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
  24. case SignInStatus.Failure:
  25. default:
  26. ModelState.AddModelError("", "Invalid login attempt.");
  27. return View(model);
  28. }
  29. }
  30.  
  31. //
  32. // Summary:
  33. // Sign in the user in using the user name and password
  34. //
  35. // Parameters:
  36. // userName:
  37. //
  38. // password:
  39. //
  40. // isPersistent:
  41. //
  42. // shouldLockout:
  43. [AsyncStateMachine(typeof(SignInManager<,>.<PasswordSignInAsync>d__29))]
  44. [DebuggerStepThrough]
  45. public virtual Task<SignInStatus> PasswordSignInAsync(string userName, string password, bool isPersistent, bool shouldLockout);
Add Comment
Please, Sign In to add comment