public static bool Login(LoginModel login) { return DataLayer.Login(login); }
public static bool Login(LoginModel login) { using (SqlConnection dbCon = ConnectToDb(DBConnString)) { SqlCommand cmdGetDetailsByCompanyName = new SqlCommand(); cmdGetDetailsByCompanyName.Connection = dbCon; cmdGetDetailsByCompanyName.CommandType = System.Data.CommandType.StoredProcedure; cmdGetDetailsByCompanyName.CommandText = "usp_CheckUser"; SqlParameter paramUserName = new SqlParameter("UserName", login.UserName); SqlParameter paramPassword = new SqlParameter("Password", login.Password); cmdGetDetailsByCompanyName.Parameters.Add(paramUserName); cmdGetDetailsByCompanyName.Parameters.Add(paramPassword); SqlDataReader dr = cmdGetDetailsByCompanyName.ExecuteReader(); if (dr.Read()) { ret = dr.GetBoolean(0); } } return ret; }
public ActionResult Login(LoginModel model, string returnUrl) { //BusinessLayer.Login(model); if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { return RedirectToLocal(returnUrl); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }