Advertisement
Guest User

Untitled

a guest
Mar 15th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. [HttpPost]
  2. [AllowAnonymous]
  3. [ValidateAntiForgeryToken]
  4. public ActionResult Login(LoginModel model, string returnUrl)
  5. {
  6.  
  7. // if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
  8. // {
  9. // return RedirectToLocal(returnUrl);
  10. // }
  11.  
  12. // If we got this far, something failed, redisplay form
  13. string query = @"
  14. SELECT [Id]
  15. ,[FirstName]
  16. ,[LastName]
  17. ,[MiddleName]
  18. ,[FullName]
  19. ,[Usercol]
  20. ,[Title]
  21. ,[PersonalEmailAddress]
  22. ,[OfficialEmailAddress]
  23. ,[JobTitle]
  24. ,[HomePhone]
  25. ,[MobilePhone]
  26. ,[OfficePhone]
  27. ,[PhotoUrl]
  28. ,[UTCConversionTimeZoneCode]
  29. ,[APIToken]
  30. ,[Country]
  31. ,[UserName]
  32. ,[Password]
  33. ,[CRMUserId]
  34. FROM User WHERE UserName = @UserName AND Password = @Password
  35. ";
  36.  
  37. UserModels UserModel = null;
  38.  
  39. using (IDbConnection db = new MySqlConnection(ConfigurationManager.ConnectionStrings["CRMPORTALSQLCONN"].ConnectionString))
  40. {
  41. UserModel = (UserModels)db.Query<UserModels>(query, new
  42. {
  43. @UserName = model.UserName,
  44. @Password = model.Password
  45. }).FirstOrDefault();
  46. }
  47. ModelState.AddModelError("", "The user name or password provided is incorrect.");
  48. return View(model);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement