コード例 #1
0
        /// <summary>
        /// 验证会员身份
        /// </summary>
        /// <param name="memberName"></param>
        public static int ValidateMember(string accountName, string passWord)
        {
            tb_Mem_Member member = QueryMemberByAccountName(accountName);

            if (member == null || member.MemberType == (short)MemberType.SysAdmin)//判断该会员账户是否存在
            {
                return((int)ErrorTypeWhenLogin.FalseAccount);
            }
            else
            {
                if (member.AccountValidTime > DateTime.Now || member.Status == (short)MemberStatus.Frozen)//判断该账户是否暂时被冻结
                {
                    return((int)ErrorTypeWhenLogin.LockedAccount);
                }
                else
                {
                    BizEnterpriseMember enterprise = new BizEnterpriseMember();
                    long tem = enterprise.GetRolesByAccountName(member.MemberID);
                    //距离上次登录失败15分钟后,将登录次数重置为0
                    if (member.AccountValidTime < DateTime.Now.AddMinutes(-15) && member.LoginCount != 0)
                    {
                        BizMember.UpdateLoginCountToZero(member.MemberID);
                    }
                    if (tem != (short)RoleType.UnCheckedEnterpriseMember && (member.Status != (short)MemberStatus.Normal))
                    {
                        return((int)ErrorTypeWhenLogin.UnActivatedAccount);
                    }
                    else
                    {
                        if (!ValidateLoginPW(accountName, passWord)) //判断账户密码是否正确
                        {                                            //输错密码一次,将登录次数加1
                            BizMember.AddLoginCount(member.MemberID);
                            BizMember.RememberFailedLoginTime(member.MemberID);
                            if (member.LoginCount == 3)
                            {   //三次输错密码后冻结账户,并将登录次数重置为0
                                BizMember.LockMember(accountName);
                                BizMember.UpdateLoginCountToZero(member.MemberID);
                                return((int)ErrorTypeWhenLogin.ThreeTimesLogin);
                            }
                            return((int)ErrorTypeWhenLogin.FalsePassword);
                        }
                        else
                        {
                            BizMember.UpdateLoginCountToZero(member.MemberID);
                            return((int)ErrorTypeWhenLogin.SuccessfulLogin);
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 验证管理员身份
        /// </summary>
        /// <param name="memberName"></param>
        public static int ValidateSysAdmin(string accountName, string passWord)
        {
            tb_Mem_Member member = QueryMemberByAccountName(accountName);

            if (member == null || member.MemberType != (short)MemberType.SysAdmin)//判断该管理员账户是否存在
            {
                return((int)ErrorTypeWhenLogin.FalseAccount);
            }
            else
            {
                if (member.Status == (short)MemberStatus.Disable)
                {
                    return((int)ErrorTypeWhenLogin.UnActivatedAccount);
                }
                else if (member.AccountValidTime > DateTime.Now)//判断该账户是否暂时被冻结
                {
                    return((int)ErrorTypeWhenLogin.LockedAccount);
                }
                else
                {   //距离上次登录失败15分钟后,将登录次数重置为0
                    if (member.AccountValidTime < DateTime.Now.AddMinutes(-15) && member.LoginCount != 0)
                    {
                        BizMember.UpdateLoginCountToZero(member.MemberID);
                    }
                    if (!ValidateLoginPW(accountName, passWord)) //判断账户密码是否正确
                    {                                            //输错密码一次,将登录次数加1
                        BizMember.AddLoginCount(member.MemberID);
                        BizMember.RememberFailedLoginTime(member.MemberID);
                        if (member.LoginCount == 3)
                        {   //三次输错密码后冻结账户,并将登录次数重置为0
                            BizMember.LockMember(accountName);
                            BizMember.UpdateLoginCountToZero(member.MemberID);
                            return((int)ErrorTypeWhenLogin.ThreeTimesLogin);
                        }
                        return((int)ErrorTypeWhenLogin.FalsePassword);
                    }
                    else
                    {
                        BizMember.UpdateLoginCountToZero(member.MemberID);
                        return((int)ErrorTypeWhenLogin.SuccessfulLogin);
                    }
                }
            }
        }