Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public ActionResult Login(LogOnModel model, string returnUrl)
 {
     return LogOnLogic(model, returnUrl, "Login");
 }
Exemplo n.º 3
0
        public ActionResult CaptchaLogin(LogOnModel model, string returnUrl)
        {
            if (PerformRecaptcha())
                ClearLoginAttempts();

            return LogOnLogic(model, returnUrl, "Captcha");
        }