Beispiel #1
0
        public static TB_USER BringUser()
        {
            Account_DBEntities AccountDB = new Account_DBEntities();

            if (General.Session[Static.Session.User] == null)
            {
                if (new HttpRequestWrapper(General.Request).IsAjaxRequest())
                {
                    return(null);
                }
                HttpCookie ck = General.Request.Cookies[Static.Session.User];
                if (ck == null)
                {
                    return(null);
                }
                else
                {
                    int ID = 0;
                    int.TryParse(Crypto.DecryptStringAES(ck.Value, Static.Cookie.SharedSecret), out ID);
                    if (ID <= 0)
                    {
                        return(null);
                    }

                    if (!SingleUser.CookieIdExist(ID))
                    {
                        return(null);
                    }
                    TB_USER User = AccountDB.TB_USER.FirstOrDefault(d => d.Id == ID);
                    if (User != null)
                    {
                        LoadUser(User);
                    }
                    else
                    {
                        return(null);
                    }
                    return(User);
                }
            }
            else
            {
                TB_USER User = General.Session[Static.Session.User] as TB_USER;
                if (!SingleUser.CookieIdExist(User.Id))
                {
                    return(null);
                }
                return(User);
            }
        }