示例#1
0
        public void Modified(object modifiled, DateTime timestamp)
        {
            Guid currentId = this.CurrentUserId ?? Guid.Empty;

            if (currentId == Guid.Empty)
            {
                throw new InvalidOperationException("IAudit User not defined.");
            }

            // Step 1. IAudit
            IAudit audit = modifiled as IAudit;

            if (audit != null)
            {
                audit.UpdatedById = currentId;
                audit.Updated     = timestamp;
            }

            CacheHelper2.Notify(modifiled, this.Message, CacheActionTypes.Update);
        }
示例#2
0
        /// <summary>
        /// 验证码检测
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="verifyCode"></param>
        /// <returns></returns>
        private string CheckVerifyCode(string userName, string verifyCode)
        {
            var    msg         = "";
            string cackeKey    = $"{userIp.Replace(".", "")}{userName}";
            var    cacheHelper = new CacheHelper2();
            var    failCount   = cacheHelper.StringGet <int>(cackeKey);

            // 验证码验证
            if (Convert.ToBoolean(Constants.IS_VERIFYCODE))
            {
                // 传了就验证
                if (!string.IsNullOrWhiteSpace(verifyCode))
                {
                    if (HttpContext.Current.Session[Constants.CHECK_CODE_NAME] == null)
                    {
                        return("验证码已过期");
                    }

                    if (string.Compare(HttpContext.Current.Session[Constants.CHECK_CODE_NAME].ToString().Trim(), verifyCode, true) != 0)
                    {
                        return("请输入正确的验证码");
                    }
                    //清空session中的验证码(释放资源)
                    HttpContext.Current.Session.Remove(Constants.CHECK_CODE_NAME);
                }
                else
                {
                    // 前端默认输入3次后开启验证码,但是关闭浏览器或者清理缓存后,会失去错误次数计数
                    // 同一个ip ,用户名短时间内错误次数过多,如果绕过了前端验证,这里强制开启验证
                    if (failCount > 50)
                    {
                        return("请输入正确的验证码");
                    }
                }
            }
            return(msg);
        }
示例#3
0
 public void Deleted(object deleted, DateTime timestamp)
 {
     CacheHelper2.Notify(deleted, this.Message, CacheActionTypes.Delete);
 }