Beispiel #1
0
        public string GetUsername(IHttpCookieCollection cookies)
        {
            if (!cookies.ContainsCookie(HttpCookie.AuthenticeKey))
            {
                return(null);
            }

            var cookie        = cookies.GetCookie(HttpCookie.AuthenticeKey);
            var cookieContent = cookie.Value;
            var username      = DecryptString(cookieContent, EncryptKey);

            return(username);
        }
Beispiel #2
0
        public static MvcUserInfo GetUserData(IHttpCookieCollection cookieCollection,
                                              IUserCookieService userCookieService)
        {
            if (!cookieCollection.ContainsCookie(".auth"))
            {
                return(new MvcUserInfo());
            }

            var cookie        = cookieCollection.GetCookie(".auth");
            var cookieContent = cookie.Value;

            try
            {
                var userName = userCookieService.GetUserData(cookieContent);
                return(userName);
            }
            catch (Exception)
            {
                return(new MvcUserInfo());
            }
        }