Beispiel #1
0
        private string UserLogin(string userName, string password)
        {
            string text = string.Empty;

            Hidistro.Membership.Context.Member member = Hidistro.Membership.Context.Users.GetUser(0, userName, false, true) as Hidistro.Membership.Context.Member;
            string result;

            if (member == null || member.IsAnonymous)
            {
                result = "用户名或密码错误";
            }
            else
            {
                if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings)
                {
                    if (!member.ParentUserId.HasValue || member.ParentUserId.Value != Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId)
                    {
                        result = "您不是本站会员,请您进行注册";
                        return(result);
                    }
                }
                else
                {
                    if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
                    {
                        result = "您不是本站会员,请您进行注册";
                        return(result);
                    }
                }
                member.Password = password;
                Hidistro.Membership.Core.Enums.LoginUserStatus loginUserStatus = MemberProcessor.ValidLogin(member);
                if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.Success)
                {
                    System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                    Hidistro.Membership.Core.IUserCookie userCookie = member.GetUserCookie();
                    userCookie.WriteCookie(authCookie, 30, false);
                    ShoppingCartInfo       shoppingCart           = ShoppingCartProcessor.GetShoppingCart();
                    CookieShoppingProvider cookieShoppingProvider = CookieShoppingProvider.Instance();
                    bool flag = false;
                    if (cookieShoppingProvider.GetShoppingCart() != null && cookieShoppingProvider.GetShoppingCart().GetQuantity() > 0)
                    {
                        flag = true;
                    }
                    cookieShoppingProvider.ClearShoppingCart();
                    Hidistro.Membership.Context.HiContext.Current.User = member;
                    if (shoppingCart != null && flag)
                    {
                        ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
                    }
                    member.OnLogin();
                }
                else
                {
                    if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.AccountPending)
                    {
                        text = "用户账号还没有通过审核";
                    }
                    else
                    {
                        if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials)
                        {
                            text = "用户名或密码错误";
                        }
                        else
                        {
                            text = "未知错误";
                        }
                    }
                }
                result = text;
            }
            return(result);
        }
Beispiel #2
0
        private void Notify_Authenticated(object sender, AuthenticatedEventArgs e)
        {
            this.parameters.Add("CurrentOpenId", e.OpenId);
            Hidistro.Membership.Context.HiContext current = Hidistro.Membership.Context.HiContext.Current;
            string usernameWithOpenId = Hidistro.Membership.Core.UserHelper.GetUsernameWithOpenId(e.OpenId, this.openIdType);

            if (!string.IsNullOrEmpty(usernameWithOpenId))
            {
                Hidistro.Membership.Context.Member member = Hidistro.Membership.Context.Users.GetUser(0, usernameWithOpenId, false, true) as Hidistro.Membership.Context.Member;
                if (member == null)
                {
                    base.Response.Write("登录失败,信任登录只能用于会员登录。");
                    return;
                }
                if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings)
                {
                    if (!member.ParentUserId.HasValue || member.ParentUserId.Value != Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId)
                    {
                        base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。");
                        return;
                    }
                }
                else
                {
                    if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0)
                    {
                        base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。");
                        return;
                    }
                }
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false);
                Hidistro.Membership.Core.IUserCookie userCookie = member.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                Hidistro.Membership.Context.HiContext.Current.User = member;
                ShoppingCartInfo       shoppingCart           = ShoppingCartProcessor.GetShoppingCart();
                CookieShoppingProvider cookieShoppingProvider = CookieShoppingProvider.Instance();
                cookieShoppingProvider.ClearShoppingCart();
                current.User = member;
                bool flag = false;
                if (cookieShoppingProvider.GetShoppingCart() != null && cookieShoppingProvider.GetShoppingCart().GetQuantity() > 0)
                {
                    flag = true;
                    cookieShoppingProvider.ClearShoppingCart();
                }
                if (shoppingCart != null && flag)
                {
                    ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart);
                }
                if (!string.IsNullOrEmpty(this.parameters["token"]))
                {
                    System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + Hidistro.Membership.Context.HiContext.Current.User.UserId.ToString());
                    httpCookie.Expires = System.DateTime.Now.AddMinutes(30.0);
                    httpCookie.Value   = this.parameters["token"];
                    System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie);
                }
            }
            else
            {
                string a;
                if ((a = this.openIdType.ToLower()) != null)
                {
                    if (a == "hishop.plugins.openid.alipay.alipayservice")
                    {
                        this.SkipAlipayOpenId();
                        goto IL_288;
                    }
                    if (a == "hishop.plugins.openid.qq.qqservice")
                    {
                        this.SkipQQOpenId();
                        goto IL_288;
                    }
                    if (a == "hishop.plugins.openid.taobao.taobaoservice")
                    {
                        this.SkipTaoBaoOpenId();
                        goto IL_288;
                    }
                    if (a == "hishop.plugins.openid.sina.sinaservice")
                    {
                        this.SkipSinaOpenId();
                        goto IL_288;
                    }
                }
                this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
            }
IL_288:
            string a2 = this.parameters["HITO"];

            if (a2 == "1")
            {
                this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder"));
                return;
            }
            this.Page.Response.Redirect(Globals.GetSiteUrls().Home);
        }