Guest User

Untitled

a guest
Oct 11th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public ActionResult Login()
  2. {
  3. return View();
  4. }
  5.  
  6. [HttpPost]
  7. public ActionResult Login(LoginModel model, string returnUrl)
  8. {
  9. if (!ModelState.IsValid)
  10. return View(model);
  11.  
  12. var password = PasswordHash.Encrypt(model.Password);
  13.  
  14. var user = _userManagerService.GetUser(model.Username, password);
  15.  
  16. if (user != null)
  17. {
  18. FormsAuthHelper.SetAuthenticationCookie(Response, user);
  19.  
  20. if (returnUrl.Length > 1)
  21. {
  22. return Redirect(returnUrl);
  23. }
  24.  
  25. return RedirectToAction("Index", "Invoice");
  26. }
  27.  
  28. ModelState.AddModelError("", "The user name or password provided is incorrect.");
  29. // If we got this far, something failed, redisplay form
  30. return View(model);
  31. }
Add Comment
Please, Sign In to add comment