Exemplo n.º 1
0
        /// <summary>
        /// 密码复杂度验证
        /// </summary>
        /// <param name="pwd"></param>
        /// <returns></returns>
        private bool RandomBoolPwd(string pwd)
        {
            string result = "";

            //进行密码复杂度的校验
            var pwdRule = OperateSection.GetPwdRuleSection();

            if (pwdRule.IsValidatecComplex)//是否启用复杂度校验
            {
                var complexList = OperateSection.GetPwdComplexSetList();
                if (complexList != null && complexList.Count > 0)
                {
                    foreach (var complex in complexList)
                    {
                        if (Regex.IsMatch(pwd, complex.Regular))
                        {
                            result += complex.ErrorMsg + "\r\n";
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(result) && result.Length > 0)
            {
                //密码复杂度不通过验证
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 验证密码复杂度(不能为默认密码)和密码修改周期
        /// </summary>
        /// <param name="loginModel"></param>
        /// <param name="loginResult"></param>
        private void ValidateCycleAndComplex(LoginViewModel loginModel, AbpLoginResult <Tenant, User> loginResult)
        {
            //进行密码复杂度的校验
            var pwdRule = OperateSection.GetPwdRuleSection();

            if (pwdRule.IsValidatecComplex)//是否启用复杂度校验
            {
                var complexList = OperateSection.GetPwdComplexSetList();
                if (complexList != null && complexList.Count > 0)
                {
                    foreach (var complex in complexList)
                    {
                        if (Regex.IsMatch(loginModel.Password, complex.Regular))
                        {
                            throw new Exception("密码复杂度不够:" + complex.ErrorMsg + "。即将跳入密码修改页面...");
                        }
                    }
                }
                if (pwdRule.DefualtPwd == loginModel.Password)
                {
                    throw new Exception("不能为系统默认密码。即将跳入密码修改页面...");
                }
            }

            //密码周期性验证
            if (pwdRule.IsCycle)//启用了周期性验证
            {
                var dd         = _userPwdAppService.GetAllPwdLog(loginResult.User.Id);
                var lastPwdLog = _userPwdAppService.GetLastPwdLog(loginResult.User.Id);
                if (lastPwdLog != null)
                {
                    if (!string.IsNullOrEmpty(pwdRule.CycleTime) && Convert.ToInt32(pwdRule.CycleTime) < DateTime.Now.Subtract(lastPwdLog.CreationTime).Duration().Days)
                    {
                        throw new Exception("当前密码累计使用已超过【" + pwdRule.CycleTime + "】天,请修改密码。即将跳入密码修改页面...");
                    }
                }
            }
        }
Exemplo n.º 3
0
        private String ValidateComplex(string pwd)
        {
            string result = "";

            //进行密码复杂度的校验
            var pwdRule = OperateSection.GetPwdRuleSection();

            if (pwdRule.IsValidatecComplex)//是否启用复杂度校验
            {
                var complexList = OperateSection.GetPwdComplexSetList();
                if (complexList != null && complexList.Count > 0)
                {
                    foreach (var complex in complexList)
                    {
                        if (Regex.IsMatch(pwd, complex.Regular))
                        {
                            result += complex.ErrorMsg + "\r\n";
                        }
                    }
                }
            }
            return(result);
        }