public ActionResult LogOn(WebstoreUser model, string returnUrl) { if (ModelState.IsValid) { if (Membership.ValidateUser(model.UserName, model.Password)) { if (CustomerInDB(model)) { MigrateShoppingCart(model.UserName); FormsAuthentication.SetAuthCookie(model.UserName, true); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } // If we got this far, something failed, redisplay form return(View(model)); }
// // POST: /Account/LogOn public bool CustomerInDB(WebstoreUser model) { List <Customer> customerList = webstoreDB.customer.ToList(); foreach (var customer in customerList) { if ((model.UserName == customer.email) && (model.Password == customer.password)) { return(true); } } return(false); }