示例#1
0
        private void btnAdminLogin_Click(object sender, System.EventArgs e)
        {
            if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtCode.Text.Trim()))
            {
                this.ShowMessage("验证码不正确");
                return;
            }
            Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(0, this.txtAdminName.Text, false, true);
            if (user == null || user.IsAnonymous || user.UserRole != Hidistro.Membership.Core.Enums.UserRole.SiteManager || !user.IsInRole("区域发货点"))
            {
                this.ShowMessage("无效的用户信息");
                return;
            }
            string text = null;

            Hidistro.Membership.Context.SiteManager siteManager = user as Hidistro.Membership.Context.SiteManager;
            siteManager.Password = this.txtAdminPassWord.Text;
            Hidistro.Membership.Core.Enums.LoginUserStatus loginUserStatus = ManagerHelper.ValidLogin(siteManager);
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.Success)
            {
                System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(siteManager.Username, false);
                Hidistro.Membership.Core.IUserCookie userCookie = siteManager.GetUserCookie();
                userCookie.WriteCookie(authCookie, 30, false);
                Hidistro.Membership.Context.HiContext.Current.User = siteManager;
                if (!string.IsNullOrEmpty(this.Page.Request.QueryString["returnUrl"]))
                {
                    text = this.Page.Request.QueryString["returnUrl"];
                }
                if (text == null && this.ReferralLink != null && !string.IsNullOrEmpty(this.ReferralLink.Trim()))
                {
                    text = this.ReferralLink;
                }
                if (!string.IsNullOrEmpty(text) && (text.ToLower().IndexOf(Globals.GetSiteUrls().Logout.ToLower()) >= 0 || text.ToLower().IndexOf(Globals.GetSiteUrls().UrlData.FormatUrl("register").ToLower()) >= 0 || text.ToLower().IndexOf(Globals.GetSiteUrls().UrlData.FormatUrl("vote").ToLower()) >= 0 || text.ToLower().IndexOf("loginexit") >= 0))
                {
                }
                this.Page.Response.Redirect("default.html", true);
                return;
            }
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.AccountPending)
            {
                this.ShowMessage("用户账号还没有通过审核");
                return;
            }
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.AccountLockedOut)
            {
                this.ShowMessage("用户账号已被锁定,暂时不能登录系统");
                return;
            }
            if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials)
            {
                this.ShowMessage("用户名或密码错误");
                return;
            }
            this.ShowMessage("登录失败,未知错误");
        }
示例#2
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);
        }
示例#3
0
 private void btnLogin_Click(object sender, System.EventArgs e)
 {
     if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtCode.Text.Trim()))
     {
         this.ShowMessage("验证码不正确", false);
     }
     else
     {
         Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(0, this.txtUserName.Text, false, true);
         if (user == null || user.IsAnonymous || user.UserRole != Hidistro.Membership.Core.Enums.UserRole.Distributor)
         {
             this.ShowMessage("无效的用户信息", false);
         }
         else
         {
             Hidistro.Membership.Context.Distributor distributor = user as Hidistro.Membership.Context.Distributor;
             distributor.Password = this.txtPassword.Text;
             if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings && user.UserId != Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId.Value)
             {
                 this.ShowMessage("分销商只能在自己的站点或主站上登录", false);
             }
             else
             {
                 Hidistro.Membership.Core.Enums.LoginUserStatus loginUserStatus = SubsiteStoreHelper.ValidLogin(distributor);
                 if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.Success)
                 {
                     System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(distributor.Username, false);
                     Hidistro.Membership.Core.IUserCookie userCookie = distributor.GetUserCookie();
                     userCookie.WriteCookie(authCookie, 30, false);
                     this.Page.Response.Cookies["hishopLoginStatus"].Value = "true";
                     Hidistro.Membership.Context.HiContext.Current.User    = distributor;
                     distributor.OnLogin();
                     Hidistro.Membership.Context.SiteSettings siteSettings = Hidistro.Membership.Context.SettingsManager.GetSiteSettings(Hidistro.Membership.Context.HiContext.Current.User.UserId);
                     if (siteSettings == null)
                     {
                         this.Page.Response.Redirect("nositedefault.aspx", true);
                     }
                     else
                     {
                         this.Page.Response.Redirect("default.aspx", true);
                     }
                 }
                 else
                 {
                     if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.AccountPending)
                     {
                         this.ShowMessage("用户账号还没有通过审核", false);
                     }
                     else
                     {
                         if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.AccountLockedOut)
                         {
                             this.ShowMessage("用户账号已被锁定,暂时不能登录系统", false);
                         }
                         else
                         {
                             if (loginUserStatus == Hidistro.Membership.Core.Enums.LoginUserStatus.InvalidCredentials)
                             {
                                 this.ShowMessage("用户名或密码错误", false);
                             }
                             else
                             {
                                 this.ShowMessage("登录失败,未知错误", false);
                             }
                         }
                     }
                 }
             }
         }
     }
 }