Exemplo n.º 1
0
        protected virtual void SetSellerAdminLoginCookie(long sellerAdminId, DateTime?expiredTime = new DateTime?())
        {
            string str = UserCookieEncryptHelper.Encrypt(sellerAdminId, "1");

            if (expiredTime.HasValue)
            {
                WebHelper.SetCookie("Himall-SellerManager", str, expiredTime.Value);
            }
            else
            {
                WebHelper.SetCookie("Himall-SellerManager", str);
            }
        }
Exemplo n.º 2
0
        protected virtual void SetUserLoginCookie(long userId, DateTime?expiredTime = new DateTime?())
        {
            string str = UserCookieEncryptHelper.Encrypt(userId, "2");

            if (expiredTime.HasValue)
            {
                WebHelper.SetCookie("Himall-User", str, expiredTime.Value);
            }
            else
            {
                WebHelper.SetCookie("Himall-User", str);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置SellerAdmin登录cookie
        /// </summary>
        /// <param name="sellerAdminId">SellerAdmin的id</param>
        /// <param name="expiredTime">cookie过期时间</param>
        protected virtual void SetSellerAdminLoginCookie(long sellerAdminId, DateTime?expiredTime = null)
        {
            var cookieValue = UserCookieEncryptHelper.Encrypt(sellerAdminId, CookieKeysCollection.USERROLE_SELLERADMIN);

            if (expiredTime.HasValue)
            {
                WebHelper.SetCookie(CookieKeysCollection.SELLER_MANAGER, cookieValue, expiredTime.Value);
            }
            else
            {
                WebHelper.SetCookie(CookieKeysCollection.SELLER_MANAGER, cookieValue);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 设置普通用户登录cookie
        /// </summary>
        /// <param name="userId">登录用户的id</param>
        /// <param name="expiredTime">cookie过期时间</param>
        protected virtual void SetUserLoginCookie(long userId, DateTime?expiredTime = null)
        {
            var cookieValue = UserCookieEncryptHelper.Encrypt(userId, CookieKeysCollection.USERROLE_USER);

            if (expiredTime.HasValue)
            {
                WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER, cookieValue, expiredTime.Value);
            }
            else
            {
                WebHelper.SetCookie(CookieKeysCollection.HIMALL_USER, cookieValue);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 设置Admin登录cookie
        /// </summary>
        /// <param name="adminId">Admin的id</param>
        /// <param name="expiredTime">cookie过期时间</param>
        protected virtual void SetAdminLoginCookie(long adminId, DateTime?expiredTime = null)
        {
            var cookieValue = UserCookieEncryptHelper.Encrypt(adminId, CookieKeysCollection.USERROLE_ADMIN, 1);

            if (expiredTime.HasValue)
            {
                WebHelper.SetCookie(CookieKeysCollection.PLATFORM_MANAGER, cookieValue, expiredTime.Value);
            }
            else
            {
                WebHelper.SetCookie(CookieKeysCollection.PLATFORM_MANAGER, cookieValue);
            }
        }
Exemplo n.º 6
0
        private bool BindOpenIdToUser(ActionExecutingContext filterContext)
        {
            string       str;
            bool         flag        = true;
            IMobileOAuth weixinOAuth = null;

            if (base.PlatformType == Himall.Core.PlatformType.WeiXin)
            {
                weixinOAuth = new WeixinOAuth();
            }
            string.Format("/m-{0}/Login/Entrance?returnUrl={1}", base.PlatformType.ToString(), HttpUtility.UrlEncode(filterContext.HttpContext.Request.Url.ToString()));
            if (weixinOAuth == null || GetRequestType(filterContext.HttpContext.Request) != Himall.Core.PlatformType.WeiXin)
            {
                flag = false;
            }
            else
            {
                WXShopInfo wXShopInfo = new WXShopInfo();
                string     item       = filterContext.HttpContext.Request["shop"];
                MemberOpenIdInfo.AppIdTypeEnum appIdTypeEnum = MemberOpenIdInfo.AppIdTypeEnum.Normal;
                if (!string.IsNullOrEmpty(item))
                {
                    long num = 0;
                    long.TryParse(item, out num);
                    if (num > 0)
                    {
                        wXShopInfo = ServiceHelper.Create <IVShopService>().GetVShopSetting(num);
                    }
                }
                if (string.IsNullOrEmpty(wXShopInfo.AppId) || string.IsNullOrEmpty(wXShopInfo.AppSecret))
                {
                    WXShopInfo wXShopInfo1 = new WXShopInfo()
                    {
                        AppId     = base.CurrentSiteSetting.WeixinAppId,
                        AppSecret = base.CurrentSiteSetting.WeixinAppSecret,
                        Token     = base.CurrentSiteSetting.WeixinToken
                    };
                    wXShopInfo    = wXShopInfo1;
                    appIdTypeEnum = MemberOpenIdInfo.AppIdTypeEnum.Payment;
                }
                MobileOAuthUserInfo userInfoBequiet = weixinOAuth.GetUserInfo_bequiet(filterContext, out str, wXShopInfo);
                if (!string.IsNullOrWhiteSpace(str))
                {
                    filterContext.Result = Redirect(str);
                }
                else
                {
                    flag = false;
                    if (userInfoBequiet != null && !string.IsNullOrWhiteSpace(userInfoBequiet.OpenId))
                    {
                        if (appIdTypeEnum == MemberOpenIdInfo.AppIdTypeEnum.Payment)
                        {
                            string str1 = SecureHelper.AESEncrypt(userInfoBequiet.OpenId, "Mobile");
                            WebHelper.SetCookie("Himall-User_OpenId", str1);
                        }
                        IMemberService memberService  = ServiceHelper.Create <IMemberService>();
                        UserMemberInfo memberByOpenId = null;
                        if (memberByOpenId == null)
                        {
                            memberByOpenId = memberService.GetMemberByOpenId(userInfoBequiet.LoginProvider, userInfoBequiet.OpenId);
                        }
                        if (memberByOpenId == null)
                        {
                            memberService.BindMember(base.CurrentUser.Id, "Himall.Plugin.OAuth.WeiXin", userInfoBequiet.OpenId, appIdTypeEnum, null, userInfoBequiet.UnionId);
                        }
                        else
                        {
                            string str2 = UserCookieEncryptHelper.Encrypt(memberByOpenId.Id, "Mobile");
                            WebHelper.SetCookie("Himall-User", str2);
                        }
                    }
                }
            }
            return(flag);
        }
Exemplo n.º 7
0
        private bool ProcessInvalidUser_NormalRequest(ActionExecutingContext filterContext)
        {
            string       str;
            bool         flag        = true;
            IMobileOAuth weixinOAuth = null;

            if (base.PlatformType == Himall.Core.PlatformType.WeiXin)
            {
                weixinOAuth = new WeixinOAuth();
            }
            string str1 = string.Format("/m-{0}/Login/Entrance?returnUrl={1}", base.PlatformType.ToString(), HttpUtility.UrlEncode(filterContext.HttpContext.Request.Url.ToString()));

            if (weixinOAuth == null || GetRequestType(filterContext.HttpContext.Request) != Himall.Core.PlatformType.WeiXin)
            {
                filterContext.Result = Redirect(str1);
            }
            else
            {
                WXShopInfo wXShopInfo = new WXShopInfo();
                string     item       = filterContext.HttpContext.Request["shop"];
                MemberOpenIdInfo.AppIdTypeEnum appIdTypeEnum = MemberOpenIdInfo.AppIdTypeEnum.Normal;
                if (!string.IsNullOrEmpty(item))
                {
                    long num = 0;
                    long.TryParse(item, out num);
                    if (num > 0)
                    {
                        wXShopInfo = ServiceHelper.Create <IVShopService>().GetVShopSetting(num);
                    }
                }
                if (string.IsNullOrEmpty(wXShopInfo.AppId) || string.IsNullOrEmpty(wXShopInfo.AppSecret))
                {
                    WXShopInfo wXShopInfo1 = new WXShopInfo()
                    {
                        AppId     = base.CurrentSiteSetting.WeixinAppId,
                        AppSecret = base.CurrentSiteSetting.WeixinAppSecret,
                        Token     = base.CurrentSiteSetting.WeixinToken
                    };
                    wXShopInfo    = wXShopInfo1;
                    appIdTypeEnum = MemberOpenIdInfo.AppIdTypeEnum.Payment;
                }
                MobileOAuthUserInfo userInfo = weixinOAuth.GetUserInfo(filterContext, out str, wXShopInfo);
                if (!string.IsNullOrWhiteSpace(str))
                {
                    filterContext.Result = Redirect(str);
                }
                else if (userInfo == null || string.IsNullOrWhiteSpace(userInfo.OpenId))
                {
                    filterContext.Result = Redirect(str1);
                }
                else
                {
                    if (appIdTypeEnum == MemberOpenIdInfo.AppIdTypeEnum.Payment)
                    {
                        string str2 = SecureHelper.AESEncrypt(userInfo.OpenId, "Mobile");
                        WebHelper.SetCookie("Himall-User_OpenId", str2);
                    }
                    UserMemberInfo memberByOpenId = null;
                    if (memberByOpenId == null)
                    {
                        memberByOpenId = ServiceHelper.Create <IMemberService>().GetMemberByOpenId(userInfo.LoginProvider, userInfo.OpenId);
                    }
                    if (memberByOpenId == null)
                    {
                        object[] objArray = new object[] { base.PlatformType.ToString(), userInfo.OpenId, "Himall.Plugin.OAuth.WeiXin", HttpUtility.UrlEncode(userInfo.NickName), HttpUtility.UrlEncode(userInfo.RealName), HttpUtility.UrlEncode(userInfo.Headimgurl), HttpUtility.UrlEncode(filterContext.HttpContext.Request.Url.ToString()), appIdTypeEnum, userInfo.UnionId };
                        str1 = string.Format("/m-{0}/Login/Entrance?openId={1}&serviceProvider={2}&nickName={3}&realName={4}&headimgurl={5}&returnUrl={6}&AppidType={7}&unionid={8}", objArray);
                        filterContext.Result = Redirect(str1);
                    }
                    else
                    {
                        string str3 = UserCookieEncryptHelper.Encrypt(memberByOpenId.Id, "Mobile");
                        WebHelper.SetCookie("Himall-User", str3);
                    }
                }
            }
            return(flag);
        }