public virtual ActionResult LogOn(LogOnViewModel model, string returnUrl) { if (ModelState.IsValid) { var userName = membershipService.GetUserNameByEmail(model.UserName); if (userName == null) { userName = model.UserName; } var user = membershipService.GetUser(userName); bool configLoadProblem = false; if (authenticationService.LogOn(userName, model.Password, model.RememberMe)) { if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } configLoadProblem = SessionContainer.Create(user) == null; if (!configLoadProblem) { return(RedirectToAction("Index", "LandingPage/Dashboard")); } } if (configLoadProblem) { ModelState.AddModelError("", "There was a problem loading the configuration for this user account."); } else { if (user == null) { ModelState.AddModelError("", "This account does not exist. Please try again."); } else { if (!user.IsApproved) { ModelState.AddModelError("", "Your account has not been approved yet."); } else if (user.IsLockedOut) { ModelState.AddModelError("", "Your account is currently locked."); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } } } // If we got this far, something failed, redisplay form return(RedirectToAction("LogOn")); }