Beispiel #1
0
 public LoginUserInfo GetLoginedUserInfo()
 {
     LoginUserInfo userInfo = new LoginUserInfo();
     try
     {
         var cookieInfo = _GetCookie();
         if (cookieInfo.Length == 6)
         {
             userInfo.UserId = Controleng.Common.Utils.StrToInt(cookieInfo[0], 0);
             userInfo.UserName = cookieInfo[1];
             userInfo.RoleId = Controleng.Common.Utils.StrToInt(cookieInfo[4], 0);
             userInfo.Password = cookieInfo[2];
             userInfo.Email = cookieInfo[3];
         }
     }
     catch
     {
         return userInfo;
     }
     return userInfo;
 }
Beispiel #2
0
        public void WriteLoginCookie(LoginUserInfo userInfo)
        {
            //正确,开始写Cookie                            
            //Cookie格式Id|UserName|Password|Email|Type|DateTime.Now
            string cookieValue = string.Format("{0}|{1}|{2}|{3}|{4}|{5}",
                userInfo.UserId,
                userInfo.UserName,
                userInfo.Password,
                userInfo.Email,
                userInfo.RoleId,
                DateTime.Now);
            //过期时间
            int expire = Controleng.Common.Utils.StrToInt
(System.Configuration.ConfigurationManager.AppSettings["LoginCookieExpires"], 60);
            //Domain
            string domain = System.Configuration.ConfigurationManager.AppSettings["LoginCookieDomain"];


            //添加到浏览器中
            //Cookie加密
            string cv = Encrypt(cookieValue,DESKey);
            HttpContext.Current.Response.Cookies.Add(new HttpCookie(CookieName, cv) { Expires = DateTime.Now.AddMinutes(expire), Domain = domain });
        }
Beispiel #3
0
        /// <summary>
        /// 验证COOKIE登录
        /// </summary>
        /// <returns></returns>
        public bool IsClientLogin()
        {
            LoginUserInfo userinfo = GetLoginedUserInfo();

            return(userinfo.UserId > 0);
        }
Beispiel #4
0
        public int GetLoginedUserId()
        {
            LoginUserInfo userinfo = GetLoginedUserInfo();

            return(userinfo.UserId);
        }
Beispiel #5
0
 public PlantEngContext() {
     ILoginAdapter login = new LoginAdapter();
     if(login.IsClientLogin()){
         LoginUserInfo = login.GetLoginedUserInfo();
     }
 }