Beispiel #1
0
        private static int CheckErrorCount(SecurityVerification verifier, string errorCountKey)
        {
            int.TryParse(RedisHelper.StringGet(Configs.RedisIndex_Web_Verify, errorCountKey), out int errorCount);

            if (errorCount >= verifier.GetVerifyFailedMaxCount())
            {
                var minCount = GetErrorLockTime(errorCountKey);
                verifier.FailedMoreTimes(minCount);
            }
            return(errorCount);
        }
Beispiel #2
0
        private static void IncreaseErrorCount(SecurityVerification verifier, string errorCountKey)
        {
            var errorCountsStr = RedisHelper.StringGet(Configs.RedisIndex_Web_Verify, errorCountKey);

            int.TryParse(errorCountsStr, out int errorCount);
            ++errorCount;
            RedisHelper.StringSet(Configs.RedisIndex_Web_Verify, errorCountKey, errorCount.ToString(), TimeSpan.FromMinutes(verifier.GetVerifyFailedLockTime()));
            if (errorCount >= verifier.GetVerifyFailedMaxCount())
            {
                var minCount = GetErrorLockTime(errorCountKey);
                verifier.FailedMoreTimes(minCount);
            }
            else
            {
                verifier.VerifyFaild(verifier.GetVerifyFailedMaxCount() - errorCount);
            }
        }