コード例 #1
0
        /// <summary>
        /// 根据传过来的键值获取当前登录用户中的cookie信息
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public List <string> GetLoginUserInfo(string[] keys)
        {
            var           loginUser = HttpContext.Current.Request.Cookies.Get("LoginUser");
            CryptManage   crypt     = new CryptManage();
            List <string> s         = new List <string>();

            foreach (string k in keys)
            {
                switch (k)
                {
                case CookieKeys.ID: s.Add(crypt.Decrypto(loginUser["ID"])); break;

                case CookieKeys.USERNAME: s.Add(HttpUtility.UrlDecode(loginUser["UserName"])); break;

                case CookieKeys.REGISTERNAME: s.Add(HttpUtility.UrlDecode(loginUser["RegisterName"])); break;

                case CookieKeys.USERDUTY: s.Add(HttpUtility.UrlDecode(loginUser["UserDuty"])); break;

                case CookieKeys.DEPARTMENTID: s.Add(crypt.Decrypto(loginUser["DepartmentID"])); break;

                case CookieKeys.PARENTDEPARTMENTID: s.Add(crypt.Decrypto(loginUser["ParentDepartmentID"])); break;

                case CookieKeys.USERGXID: s.Add(crypt.Decrypto(loginUser["UserGxID"])); break;

                case CookieKeys.USERROLES: s.Add(crypt.Decrypto(loginUser["UserRoles"])); break;

                case CookieKeys.USERROLENAMES: s.Add(HttpUtility.UrlDecode(loginUser["UserRoleNames"])); break;
                }
            }
            return(s);
        }
コード例 #2
0
        /// <summary>
        /// 用户登录成功,将ID等相关重要信息写入cookie中
        /// </summary>
        private void LoginConfirm(tblUserInfo model, HttpResponseBase Response)
        {
            CryptManage crypt  = new CryptManage();
            HttpCookie  cookie = new HttpCookie("LoginUser");

            cookie.Expires = DateTime.Now.AddMinutes(30);

            DepartmentInfoDataTreeManage tree   = new DepartmentInfoDataTreeManage();
            tblDepartmentInfo            parent = tree.GetFirstParent(Convert.ToInt64(model.UserIDepartmentIID));

            cookie.Values.Add("ID", crypt.Encrypto(model.ID.ToString()));
            cookie.Values.Add("UserName", HttpUtility.UrlEncode(model.Name));
            cookie.Values.Add("RegisterName", HttpUtility.UrlEncode(model.UserICode));
            cookie.Values.Add("UserDuty", HttpUtility.UrlEncode(model.DutyInfo.Name));
            cookie.Values.Add("DepartmentID", crypt.Encrypto(model.UserIDepartmentIID.ToString()));
            if (parent != null)
            {
                cookie.Values.Add("ParentDepartmentID", crypt.Encrypto(parent.ID.ToString()));
                cookie.Values.Add("UserGxID", crypt.Encrypto(parent.GxID.ToString()));
            }
            else
            {
                cookie.Values.Add("ParentDepartmentID", crypt.Encrypto("0"));
                cookie.Values.Add("UserGxID", crypt.Encrypto("0"));
            }
            string sUserRoles     = string.Join(CosValue.SPLITOPERATOR2.ToString(), model.authorRelations.Select(x => x.author.ID).ToArray());
            string sUserRoleNames = HttpUtility.UrlEncode(string.Join(CosValue.SPLITOPERATOR1.ToString(), model.authorRelations.Select(x => x.author.Name).ToArray()));

            cookie.Values.Add("UserRoles", crypt.Encrypto(sUserRoles));
            cookie.Values.Add("UserRoleNames", sUserRoleNames);

            Response.Cookies.Add(cookie);
        }
コード例 #3
0
        /// <summary>
        /// 对密码进行加密
        /// </summary>
        /// <param name="sPass"></param>
        /// <returns></returns>
        public string GetSecretPass(string sPass)
        {
            CryptManage crypt = new CryptManage();

            return(crypt.Encrypto(sPass));
        }
コード例 #4
0
        /// <summary>
        /// 获得解密后的密码
        /// </summary>
        /// <param name="sPass"></param>
        /// <returns></returns>
        public string GetRealPass(string sPass)
        {
            CryptManage crypt = new CryptManage();

            return(crypt.Decrypto(sPass));
        }