예제 #1
0
        public static XSRF CreateXSRF(string SecurityDateTime = null, string Token = null)
        {
            XSRF item = new XSRF();

            if (SecurityDateTime == null || SecurityDateTime == "")
            {
                item.DateTime = string.Format("{0:ddMMyyHHmmss}", DateTime.Now);
            }
            string Secret = USUsersService.SecretXSRF + item.DateTime + Token;

            item.X_XSRF_TOKEN = USUsersService.GetMD5(Secret);
            return(item);
        }
예제 #2
0
        public static Boolean CheckXSRF(XSRF item)
        {
            Boolean flag = false;

            try
            {
                string Secret       = USUsersService.SecretXSRF + item.DateTime + item.Token;
                string X_XSRF_TOKEN = USUsersService.GetMD5(Secret);
                if (X_XSRF_TOKEN == item.X_XSRF_TOKEN)
                {
                    flag = true;
                }
                return(flag);
            }
            catch
            {
                return(false);
            }
        }
예제 #3
0
        public static USUsers CheckLogin(string UserName, string Password)
        {
            string    md5pass = USUsersService.GetMD5(Password);
            DataTable tabl    = ConnectDb.ExecuteDataTableTask(Startup.ConnectionString, "user_users",
                                                               new string[] { "@flag", "@UserName", "@Password" },
                                                               new object[] { "Login", UserName.ToLower(), md5pass });

            return((from r in tabl.AsEnumerable()
                    select new USUsers
            {
                Id = (int)r["Id"],
                IdGroup = (int)r["IdGroup"],
                UserName = (string)r["UserName"],
                Avatar = (string)((r["Avatar"] == System.DBNull.Value) ? "" : r["Avatar"]),
                FullName = (string)((r["FullName"] == System.DBNull.Value) ? "" : r["FullName"]),
                UserCode = (string)((r["UserCode"] == System.DBNull.Value) ? "" : r["UserCode"]),
                Gender = (byte)r["Gender"],
                IdCoQuan = (int)r["IdCoQuan"],
                TenCoQuan = (string)((r["TenCoQuan"] == System.DBNull.Value) ? "" : r["TenCoQuan"]),
                Email = (string)((r["Email"] == System.DBNull.Value) ? "" : r["Email"]),
                Telephone = (string)((r["Telephone"] == System.DBNull.Value) ? "" : r["Telephone"]),
            }).FirstOrDefault());
        }