コード例 #1
0
        public static bool GetBool(this IDistributedCache distributedCache, string key, bool defaultValue)
        {
            var number = distributedCache.GetInt(key);

            if (number == null)
            {
                return(defaultValue);
            }
            return(number.Value == 1);
        }
コード例 #2
0
ファイル: AuthController.cs プロジェクト: hyfree/MoreNote
        //public IActionResult Index()
        //{
        //    return View();
        //}
        /// <summary>
        /// 登录 页面
        /// </summary>
        /// <returns></returns>
        public IActionResult Login()
        {
            var number = distributedCache.GetInt(errorCountKey);

            ViewBag.Title = "请登录";
            SetLocale();
            ConfigSetting configSetting = new ConfigSetting();

            ViewBag.quickLogin    = Request.Cookies["token"] != null;
            ViewBag.ConfigSetting = configSetting;
            //是否需要验证码服务
            if (this.config.SecurityConfig.NeedVerificationCode == NeedVerificationCode.OFF ||
                ((this.config.SecurityConfig.NeedVerificationCode == NeedVerificationCode.AUTO) && number < 10))
            {
                ViewBag.needCaptcha = "false";
            }
            else
            {
                ViewBag.needCaptcha = "true";
            }
            ViewBag.errorCount = number;

            return(View());
        }