コード例 #1
0
ファイル: Fetch.cs プロジェクト: generalSun/HappyWebWH
 /// <summary>
 /// 大厅登陆写入cookie
 /// </summary>
 public static string PalaformWriteCookie()
 {
     if (HttpContext.Current.Request.Cookies["Accounts"] != null && HttpContext.Current.Request.Cookies["Password"] != null)
     {
         string accounts = HttpContext.Current.Request.Cookies["Accounts"].Value.ToString();
         string password = HttpContext.Current.Request.Cookies["Password"].Value.ToString();
         password = password.Trim();
         accounts = accounts.Trim();
         UserInfo suInfo = new UserInfo(0, accounts, 0);
         suInfo.LastLogonIP = GameRequest.GetUserIP();
         Message umsg = FacadeManage.aideAccountsFacade.Logon(suInfo, true);
         if (umsg.Success)
         {
             UserInfo ui = umsg.EntityList[0] as UserInfo;
             ui.LogonPass = password.Trim();
             Fetch.SetUserCookie(ui.ToUserTicketInfo());
             object obj = WHCache.Default.Get <CookiesCache>(AppConfig.UserLoginCacheKey);
             if (obj != null)
             {
                 return(obj.ToString());
             }
         }
     }
     return("");
 }
コード例 #2
0
 public static string PalaformWriteCookie()
 {
     if (HttpContext.Current.Request.Cookies["Accounts"] != null && HttpContext.Current.Request.Cookies["Password"] != null)
     {
         string str  = HttpContext.Current.Request.Cookies["Accounts"].Value.ToString();
         string str1 = HttpContext.Current.Request.Cookies["Password"].Value.ToString();
         str1 = str1.Trim();
         UserInfo userInfo = new UserInfo(0, str.Trim(), 0)
         {
             LastLogonIP = GameRequest.GetUserIP()
         };
         Message message = FacadeManage.aideAccountsFacade.Logon(userInfo, true);
         if (message.Success)
         {
             UserInfo item = message.EntityList[0] as UserInfo;
             item.LogonPass = str1.Trim();
             Fetch.SetUserCookie(item.ToUserTicketInfo());
             object obj = WHCache.Default.Get <CookiesCache>(AppConfig.UserLoginCacheKey);
             if (obj != null)
             {
                 return(obj.ToString());
             }
         }
     }
     return("");
 }
コード例 #3
0
 public static void ReWriteUserCookie()
 {
     if (Fetch.IsUserOnline())
     {
         UserTicketInfo userCookie = Fetch.GetUserCookie();
         Message        message    = FacadeManage.aideAccountsFacade.Logon(new UserInfo(userCookie), false);
         if (message.Success)
         {
             UserInfo item = message.EntityList[0] as UserInfo;
             Fetch.SetUserCookie(item.ToUserTicketInfo());
         }
     }
 }
コード例 #4
0
ファイル: Fetch.cs プロジェクト: generalSun/HappyWebWH
        /// <summary>
        /// 登录并重写 Cookie
        /// </summary>
        public static void ReWriteUserCookie()
        {
            if (Fetch.IsUserOnline())
            {
                UserTicketInfo uti = Fetch.GetUserCookie();
                Message        msg = FacadeManage.aideAccountsFacade.Logon(new UserInfo(uti), false);
                if (msg.Success)
                {
                    UserInfo       usInfo    = msg.EntityList[0] as UserInfo;
                    UserTicketInfo utiServer = usInfo.ToUserTicketInfo();

                    Fetch.SetUserCookie(utiServer);
                }
            }
        }
コード例 #5
0
ファイル: Fetch.cs プロジェクト: archangelwin/QY
        /// <summary>
        /// 后台登录并重写 Cookie
        /// </summary>
        public static void ReWriteUserCookie()
        {
            if (Fetch.IsUserOnline())
            {
                UserTicketInfo uti = Fetch.GetUserCookie();
                Message        msg = accountsData.Logon(new UserInfo(uti), false);
                if (msg.Success)
                {
                    UserInfo       usInfo    = msg.EntityList[0] as UserInfo;
                    UserTicketInfo utiServer = usInfo.ToUserTicketInfo();
                    utiServer.LogonPass = uti.LogonPass;

                    Fetch.SetUserCookie(utiServer);
                }
            }
        }
コード例 #6
0
ファイル: Fetch.cs プロジェクト: archangelwin/QY
 /// <summary>
 /// 大厅登陆写入cookie
 /// </summary>
 public static string PalaformWriteCookie()
 {
     if (HttpContext.Current.Request.Cookies["Accounts"] != null && HttpContext.Current.Request.Cookies["Password"] != null)
     {
         string accounts = HttpContext.Current.Request.Cookies["Accounts"].Value.ToString();
         string password = HttpContext.Current.Request.Cookies["Password"].Value.ToString();
         password = password.Trim();
         accounts = accounts.Trim();
         UserInfo suInfo = new UserInfo(0, accounts, 0, password.Trim());
         suInfo.LastLogonIP = GameRequest.GetUserIP();
         AccountsFacade accountsFacade = new AccountsFacade();
         Message        umsg           = accountsFacade.Logon(suInfo, true);
         if (umsg.Success)
         {
             UserInfo ui = umsg.EntityList[0] as UserInfo;
             ui.LogonPass = password.Trim();
             Fetch.SetUserCookie(ui.ToUserTicketInfo());
             return(Fetch.GetCookie(Fetch.UC_COOKIE_LOGON_TOKEN));
         }
     }
     return("");
 }
コード例 #7
0
        /// <summary>
        /// 获取用户对象
        /// </summary>
        /// <returns></returns>
        public static UserTicketInfo GetUserCookie()
        {
            string plaintext = Fetch.GetCookie(Fetch.UC_COOKIE_LOGON_TOKEN);

            //平台跳转判断是否登录
            if (HttpContext.Current.Request.Cookies["Accounts"] != null && HttpContext.Current.Request.Cookies["Password"] != null && TextUtility.EmptyTrimOrNull(plaintext))
            {
                string accounts = HttpContext.Current.Request.Cookies["Accounts"].Value.ToString();
                string password = HttpContext.Current.Request.Cookies["Password"].Value.ToString();
                password = password.Trim();
                accounts = accounts.Trim();
                UserInfo suInfo = new UserInfo(0, accounts, 0, password.Trim());
                suInfo.LastLogonIP = GameRequest.GetUserIP();
                AccountsFacade accountsFacade = new AccountsFacade();
                Message        umsg           = accountsFacade.Logon(suInfo, true);
                if (umsg.Success)
                {
                    UserInfo ui = umsg.EntityList[0] as UserInfo;
                    ui.LogonPass = password.Trim();
                    Fetch.SetUserCookie(ui.ToUserTicketInfo());
                    plaintext = Fetch.GetCookie(Fetch.UC_COOKIE_LOGON_TOKEN);
                }
            }

            if (TextUtility.EmptyTrimOrNull(plaintext))
            {
                return(null);
            }

            string jsonText = Utils.AES.Decrypt(plaintext, CookieEncryptKey);

            if (TextUtility.EmptyTrimOrNull(jsonText))
            {
                return(null);
            }

            return(UserTicketInfo.DeserializeObject(jsonText));
        }