Exemplo n.º 1
0
 /// <summary>
 /// 执行Action时
 /// </summary>
 /// <param name="filterContext"></param>
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (CaptchaUtility.UseCaptcha(scenarios, true))
     {
         try
         {
             ICaptchaManager captchaManager = DIContainer.Resolve <ICaptchaManager>();
             Controller      controllerBase = filterContext.Controller as Controller;
             if (!captchaManager.IsCaptchaValid(filterContext))
             {
                 //controllerBase.ModelState.AddModelError("Captcha", CaptchaVerifyError);
                 controllerBase.ViewData["UserLoginStatus"] = UserLoginStatus.CapCode;
             }
             else if (controllerBase.ModelState.IsValid)
             {
                 //表单通过验证时,重设累计次数
                 //CaptchaUtility.ResetLimitTryCount(scenarios);
                 //此处修改成登录成功,重设累计次数
             }
         }
         catch
         {
             throw new Exception("检查验证码时,出现异常");
         }
     }
     base.OnActionExecuting(filterContext);
 }
Exemplo n.º 2
0
 /// <summary>
 /// 执行Action时
 /// </summary>
 /// <param name="filterContext"></param>
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (CaptchaUtility.UseCaptcha(scenarios, true))
     {
         try
         {
             ICaptchaManager captchaManager = DIContainer.Resolve <ICaptchaManager>();
             ControllerBase  controllerBase = filterContext.Controller;
             if (!captchaManager.IsCaptchaValid(filterContext))
             {
                 controllerBase.ViewData.ModelState.AddModelError("Captcha", CaptchaVerifyError);
             }
             else if (controllerBase.ViewData.ModelState.IsValid)
             {
                 //表单通过验证时,重设计数
                 CaptchaUtility.ResetLimitTryCount(scenarios);
             }
         }
         catch
         {
             throw new ExceptionFacade("检查验证码时,出现异常");
         }
     }
     base.OnActionExecuting(filterContext);
 }