public ActionResult SignIn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (this.userRepo.Exists(model.UserName)) { var user = this.userRepo.Open(model.UserName); if (!user.IsActive && this.features.RequireActivation) { return this.RedirectToAction("AwaitingAccountActivation", new { username = model.UserName }); } if (user.ValidatePassword(model.Password)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return this.Redirect(returnUrl); } return this.RedirectToAction("Index", "Home"); } } } ModelState.AddModelError(string.Empty, "The user name or password provided is incorrect."); // If we got this far, something failed, redisplay form return this.View(model); }