Exemple #1
0
        private static int CheckSendCount(SecurityVerification verifier, string sendCountKey)
        {
            int.TryParse(RedisHelper.StringGet(Configs.RedisIndex_Web_Verify, sendCountKey), out int sendCount);

            if (sendCount >= verifier.GetSendCodeMaxCount())
            {
                verifier.SendCodeMoreTimes();
            }
            return(sendCount);
        }
Exemple #2
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);
        }
Exemple #3
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);
            }
        }