Exemplo n.º 1
0
 /// <summary>
 /// 解析userKey
 /// </summary>
 /// <param name="userKey"></param>
 /// <returns></returns>
 protected virtual long DecryptUserKey(string userKey)
 {
     return(UserCookieEncryptHelper.Decrypt(userKey, CookieKeysCollection.USERROLE_USER));
 }
Exemplo n.º 2
0
        public static Entities.MemberInfo GetUser(HttpRequest request)
        {
            /*
             * long id = UserCookieEncryptHelper.Decrypt(WebHelper.GetCookie("Mall-User"), "2");
             * if (id == 0L)
             * {
             *  string userIdCookie = request.Query["token"].ToString();
             *  //string userIdCookie = Guid.NewGuid().ToString();
             *  id = UserCookieEncryptHelper.Decrypt(userIdCookie, "2");
             *  if (id != 0L)
             *  {
             *      WebHelper.SetCookie("Mall-User", userIdCookie);
             *  }
             * }
             * if (id != 0L)
             * {
             *  var userInfo = MemberApplication.GetMember(id);
             *  var siteInfo = SiteSettingApplication.SiteSettings;
             *  if (siteInfo != null)
             *  {
             *      if (!(siteInfo.IsOpenPC || siteInfo.IsOpenH5 || siteInfo.IsOpenMallSmallProg || siteInfo.IsOpenApp))//授权模块影响会员折扣功能
             *      {
             *          userInfo.MemberDiscount = 1M;
             *      }
             *
             *  }
             *  return userInfo;
             * }
             * return null;
             *
             */


            long userId = 0;
            var  token  = request.Query["token"].ToString();

            if (!string.IsNullOrEmpty(token))
            {
                userId = UserCookieEncryptHelper.Decrypt(token, CookieKeysCollection.USERROLE_USER);
                if (userId != 0)
                {
                    WebHelper.SetCookie(CookieKeysCollection.Mall_USER, token);
                }
            }
            if (userId == 0)
            {
                var cookieValue = WebHelper.GetCookie(CookieKeysCollection.Mall_USER);
                userId = UserCookieEncryptHelper.Decrypt(cookieValue, CookieKeysCollection.USERROLE_USER);
            }

            if (userId != 0)
            {
                var userInfo = MemberApplication.GetMember(userId);
                var siteInfo = SiteSettingApplication.SiteSettings;
                if (siteInfo != null)
                {
                    if (!(siteInfo.IsOpenPC || siteInfo.IsOpenH5 || siteInfo.IsOpenMallSmallProg || siteInfo.IsOpenApp))//授权模块影响会员折扣功能
                    {
                        userInfo.MemberDiscount = 1M;
                    }
                }
                return(userInfo);
            }

            return(null);
        }