Example #1
0
        /// <summary>
        /// 验证密码是否正确 2014/8/21 9:04:10   By 唐有炜
        /// </summary>
        /// <param name="accountType">账号类型(username,email,phone)</param>
        /// <param name="userName">用户名</param>
        /// <param name="userPassword">密码</param>
        /// <returns></returns>
        public bool UserPasswordExists(string accountType, string userName, string userPassword)
        {
            bool passwordExists = false;

            //解密
            userPassword = DESEncrypt.Encrypt(userPassword);

            switch (accountType)
            {
            case "username":
                passwordExists =
                    TSysUserDao.ExistsEntity(
                        u => u.UserLname == userName && u.UserPassword == userPassword);
                if (passwordExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "email":
                passwordExists =
                    TSysUserDao.ExistsEntity(
                        u => u.UserEmail == userName && u.UserPassword == userPassword);
                if (passwordExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "phone":
                passwordExists =
                    TSysUserDao.ExistsEntity(
                        u => u.UserPhone == userName && u.UserPassword == userPassword);
                if (passwordExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            default:
                return(false);

                break;
            }
        }
Example #2
0
        /// <summary>
        /// 验证用户名是否存在 2014/8/21 9:04:10   By 唐有炜
        /// </summary>
        /// <param name="accountType">账号类型(username,email,phone)</param>
        /// <param name="userName">用户名</param>
        /// <returns></returns>
        public bool UserNameExists(string accountType, string userName)
        {
            switch (accountType)
            {
            case "username":
                bool userExists = TSysUserDao.ExistsEntity(u => u.UserLname == userName);
                if (userExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "email":
                bool emailExists = TSysUserDao.ExistsEntity(u => u.UserEmail == userName);
                if (emailExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            case "phone":
                bool phoneExists = TSysUserDao.ExistsEntity(u => u.UserPhone == userName);
                if (phoneExists)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                break;

            default:
                return(false);

                break;
            }
        }