コード例 #1
0
ファイル: ProxyRequisicao.cs プロジェクト: squadratec/sqhweb
        private List <CookieResponse> GetAllCookies(CookieContainer container)
        {
            var allCookies       = new List <CookieResponse>();
            var domainTableField = container.GetType().GetRuntimeFields().FirstOrDefault(x => x.Name == "m_domainTable");
            var domains          = (IDictionary)domainTableField.GetValue(container);

            foreach (var val in domains.Values)
            {
                var type   = val.GetType().GetRuntimeFields().First(x => x.Name == "m_list");
                var values = (IDictionary)type.GetValue(val);
                foreach (CookieCollection cookies in values.Values)
                {
                    foreach (Cookie cookie in cookies)
                    {
                        CookieResponse c = new CookieResponse();
                        c.Domain    = cookie.Domain;
                        c.Expires   = cookie.Expires;
                        c.Name      = cookie.Name;
                        c.Path      = cookie.Path;
                        c.TimeStamp = cookie.TimeStamp;
                        c.Value     = cookie.Value;
                        allCookies.Add(c);
                    }
                }
            }
            return(allCookies);
        }
コード例 #2
0
        public HttpResponseMessage CheckLogin()
        {
            CookieResponse cookieResponse = new CookieResponse();

            if (User.Identity.GetId().HasValue)
            {
                cookieResponse.UserId = User.Identity.GetId().Value;
                cookieResponse.Name   = User.Identity.Name.ToString();
                cookieResponse.Roles  = User.Identity.GetRoles().ToList();

                User userInfo = userService.GetById(User.Identity.GetId().Value);
                cookieResponse.user = userInfo;

                return(Request.CreateResponse(HttpStatusCode.OK, new ItemResponse <CookieResponse> {
                    Item = cookieResponse
                }));
            }

            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, new ItemResponse <string> {
                    Item = null
                }));
            }
        }