void btnLogin_Click(object sender, EventArgs e) { if (!HiContext.Current.CheckVerifyCode(txtCode.Text.Trim())) { ShowMessage("验证码不正确", false); } else { IUser user = Users.GetUser(0, txtUserName.Text, false, true); if (((user == null) || user.IsAnonymous) || (user.UserRole != UserRole.Distributor)) { ShowMessage("无效的用户信息", false); } else { Distributor distributor = user as Distributor; distributor.Password = txtPassword.Text; if (HiContext.Current.SiteSettings.IsDistributorSettings && (user.UserId != HiContext.Current.SiteSettings.UserId.Value)) { ShowMessage("分销商只能在自己的站点或主站上登录", false); } else { LoginUserStatus status = SubsiteStoreHelper.ValidLogin(distributor); if (status == LoginUserStatus.Success) { HttpCookie authCookie = FormsAuthentication.GetAuthCookie(distributor.Username, false); distributor.GetUserCookie().WriteCookie(authCookie, 30, false); Page.Response.Cookies["hishopLoginStatus"].Value = "true"; HiContext.Current.User = distributor; distributor.OnLogin(); if (SettingsManager.GetSiteSettings(HiContext.Current.User.UserId) == null) { Page.Response.Redirect("nositedefault.aspx", true); } else { Page.Response.Redirect("default.aspx", true); } } else { switch (status) { case LoginUserStatus.AccountPending: { ShowMessage("用户账号还没有通过审核", false); return; } case LoginUserStatus.AccountLockedOut: { ShowMessage("用户账号已被锁定,暂时不能登录系统", false); return; } case LoginUserStatus.InvalidCredentials: { ShowMessage("用户名或密码错误", false); return; } } ShowMessage("登录失败,未知错误", false); } } } } }