Esempio n. 1
0
        /// <summary>
        /// 判断用户密码是否正确
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="originalpassword">是否为未MD5密码</param>
        /// <returns>如果正确则返回uid</returns>
        public static ShortUserInfo CheckPassword(string username, string password, bool originalpassword)
        {
            ShortUserInfo userInfo = null;
            if (appDBCache)
            {
                userInfo = IUserService.CheckPassword(username, password, originalpassword);
                if (userInfo != null)
                    return userInfo;
            }

            IDataReader reader = DatabaseProvider.GetInstance().CheckPassword(username, password, originalpassword);
            if (reader.Read())
            {
                userInfo = new ShortUserInfo();
                userInfo.Uid = Utils.StrToInt(reader[0].ToString(), -1);
                userInfo.Groupid = Utils.StrToInt(reader[1].ToString(), -1);
                userInfo.Adminid = Utils.StrToInt(reader[2].ToString(), -1);
            }
            reader.Close();

            if (appDBCache && userInfo.Uid > 0)
                GetUserInfo(userInfo.Uid);

            return userInfo;
        }