private ActionResult LogOnLogic(LogOnModel model, string returnUrl, string redirectToOnFailureAction) { var loginAttempts = AddLoginAttempt(); if (loginAttempts < 5) { if (ModelState.IsValid) { if (_coreEntitiesMembershipProvider.ValidateUser(model.EmailAddress, model.Password)) { //Also authenticate API ClearLoginAttempts(); FormsAuthentication.SetAuthCookie(model.EmailAddress, true); if (!String.IsNullOrEmpty(returnUrl)) return Redirect(returnUrl); return Redirect(AppConstants.ApplicationUrl); } ModelState.AddModelError("", "The email address or password provided is incorrect."); } } else { return RedirectToAction("Captcha", "Account"); } // If we got this far something failed. Display page w validation errors return View(redirectToOnFailureAction, model); }
public ActionResult Login(LogOnModel model, string returnUrl) { return LogOnLogic(model, returnUrl, "Login"); }
public ActionResult CaptchaLogin(LogOnModel model, string returnUrl) { if (PerformRecaptcha()) ClearLoginAttempts(); return LogOnLogic(model, returnUrl, "Captcha"); }