public ActionResult Login(UserViewModels.Login model) { AuthUser aa = new AuthUser(db); bool success = aa.Login(model.EmailAddress, model.Password); if (success) { return(RedirectToAction("Details", aa.Authorise())); } else { ModelState.AddModelError("EmailAddress", "That email and password combination was not recognised"); return(View()); } }
public ActionResult Index(string username, string password) { try { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { throw new Exception("Username or passsword is valid!!"); } bool ischeck = AuthUser.Login(username, password); if (!ischeck) { throw new Exception("Username or passsword is valid!!"); } System.Web.HttpContext.Current.Response.Redirect("~/" + AuthUser.Company, true); return(View()); } catch (Exception ex) { ViewBag.MessageError = ex.Message; return(View()); } }