private void btnConfirm_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtPassword.Value)) { this.message.Text = "密码不能为空"; } else if (this.txtPassword.Value != this.txtPassword2.Value) { this.message.Text = "两次密码输入不一致,请重新输入"; } else { MemberDao memberDao = new MemberDao(); bool flag = true; MemberInfo memberInfo = memberDao.FindMemberByCellphone(this.username); if (memberInfo == null) { memberInfo = memberDao.FindMemberByEmail(this.username); } if (DataHelper.IsEmail(this.username)) { flag = false; } if (memberInfo != null) { string value = this.txtNumber.Value; string text = "验证码错误"; if ((flag && HiContext.Current.CheckPhoneVerifyCode(value, memberInfo.CellPhone, out text)) || (!flag && HiContext.Current.CheckVerifyCode(value, ""))) { if (MemberProcessor.ChangePassword(memberInfo, this.txtPassword2.Value)) { Messenger.UserPasswordChanged(memberInfo, this.txtPassword2.Value); Users.SetCurrentUser(memberInfo.UserId, 1, true, false); ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } this.Page.Response.Redirect("MemberCenter.aspx", true); } } else { this.message.Text = text; } } else { this.message.Text = "密码修改失败,错误的用户名"; } } }
string UserLogin(string userName, string password) { string str = string.Empty; Member member = Users.GetUser(0, userName, false, true) as Member; if ((member == null) || member.IsAnonymous) { return("用户名或密码错误"); } if (HiContext.Current.SiteSettings.IsDistributorSettings) { if (member.ParentUserId.HasValue) { if (member.ParentUserId.Value == HiContext.Current.SiteSettings.UserId) { goto Label_00B2; } } return("您不是本站会员,请您进行注册"); } if (member.ParentUserId.HasValue && (member.ParentUserId.Value != 0)) { return("您不是本站会员,请您进行注册"); } Label_00B2: member.Password = password; switch (MemberProcessor.ValidLogin(member)) { case LoginUserStatus.AccountPending: return("用户账号还没有通过审核"); case LoginUserStatus.InvalidCredentials: return("用户名或密码错误"); case LoginUserStatus.Success: { HttpCookie authCookie = FormsAuthentication.GetAuthCookie(member.Username, false); member.GetUserCookie().WriteCookie(authCookie, 30, false); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); CookieShoppingProvider.Instance().ClearShoppingCart(); HiContext.Current.User = member; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } member.OnLogin(); return(str); } } return("未知错误"); }
private string UserLogin(string userName, string password) { string result = string.Empty; Member member = Users.GetUser(0, userName, false, true) as Member; if (member == null || member.IsAnonymous) { return("用户名或密码错误"); } if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0) { return("您不是本站会员,请您进行注册"); } member.Password = password; LoginUserStatus loginUserStatus = MemberProcessor.ValidLogin(member); if (loginUserStatus == LoginUserStatus.Success) { System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false); IUserCookie userCookie = member.GetUserCookie(); userCookie.WriteCookie(authCookie, 30, false); ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); HiContext.Current.User = member; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } member.OnLogin(); } else { if (loginUserStatus == LoginUserStatus.AccountPending) { result = "用户账号还没有通过审核"; } else { if (loginUserStatus == LoginUserStatus.InvalidCredentials) { result = "用户名或密码错误"; } else { result = "未知错误"; } } } return(result); }
private void UserLogin(string userName, string password) { userName = Globals.StripAllTags(userName); MemberInfo memberInfo = MemberProcessor.ValidLogin(userName, password); if (memberInfo != null) { Users.SetCurrentUser(memberInfo.UserId, 0, true, true); ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); HiContext.Current.User = memberInfo; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } } }
private void SetLoginState(MemberInfo member) { string text = this.parameters["HIGW"]; string openId = this.parameters["CurrentOpenId"]; MemberOpenIdInfo memberOpenId = MemberProcessor.GetMemberOpenId(text, openId); if (memberOpenId == null) { memberOpenId = new MemberOpenIdInfo(); memberOpenId.UserId = member.UserId; memberOpenId.OpenIdType = text; memberOpenId.OpenId = openId; MemberProcessor.AddMemberOpenId(memberOpenId); } Users.SetCurrentUser(member.UserId, 30, false, false); HiContext.Current.User = member; ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(this.parameters["token"])) { HttpCookie httpCookie = new HttpCookie("Token_" + HiContext.Current.UserId.ToString()); httpCookie.HttpOnly = true; httpCookie.Expires = DateTime.Now.AddMinutes(30.0); httpCookie.Value = this.parameters["token"]; HttpContext.Current.Response.Cookies.Add(httpCookie); } if (!string.IsNullOrEmpty(this.parameters["target_url"])) { this.Page.Response.Redirect(this.parameters["target_url"], true); } this.Page.Response.Redirect("/"); }
private string UserLogin(string userName, string password) { string result = string.Empty; userName = Globals.StripAllTags(userName); MemberInfo memberInfo = MemberProcessor.ValidLogin(userName, password); if (memberInfo != null) { Users.SetCurrentUser(memberInfo.UserId, (this.chkSaveLoginInfo != null && this.chkSaveLoginInfo.Checked) ? 7 : 0, true, true); HiContext.Current.User = memberInfo; ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } } else { result = "用户名或密码错误"; } return(result); }
protected override void AttachChildControls() { PageTitle.AddSiteNameTitle("会员中心"); Member member = HiContext.Current.User as Member; if (member == null) { this.Page.Response.Redirect("/Vshop/Login.aspx"); } this.litUserLink = (System.Web.UI.WebControls.Literal) this.FindControl("litUserLink"); this.litUserName = (System.Web.UI.WebControls.Literal) this.FindControl("litUserName"); this.litPaymentBalance = (System.Web.UI.WebControls.Literal) this.FindControl("litPaymentBalance"); this.litExpenditure = (System.Web.UI.WebControls.Literal) this.FindControl("litExpenditure"); this.litExpenditure.SetWhenIsNotNull(member.Expenditure.ToString("F2")); this.litPaymentBalance.SetWhenIsNotNull(member.Balance.ToString("F2")); this.litPoints = (System.Web.UI.WebControls.Literal) this.FindControl("litPoints"); this.referralLink = (System.Web.UI.WebControls.HyperLink) this.FindControl("referralLink"); this.bindAccountLink = (System.Web.UI.WebControls.HyperLink) this.FindControl("bindAccountLink"); this.litAllOrderCount = (System.Web.UI.WebControls.Literal) this.FindControl("litAllOrderCount"); this.litRefundCount = (System.Web.UI.WebControls.Literal) this.FindControl("litRefundCount"); this.litReturnCount = (System.Web.UI.WebControls.Literal) this.FindControl("litReturnCount"); this.litReplaceCount = (System.Web.UI.WebControls.Literal) this.FindControl("litReplaceCount"); this.switchAccountLink = (System.Web.UI.WebControls.HyperLink) this.FindControl("switchAccountLink"); this.litCoupons = (System.Web.UI.WebControls.Literal) this.FindControl("litCoupons"); this.litVoucher = (System.Web.UI.WebControls.Literal) this.FindControl("litVoucher"); this.litBindPhone = (System.Web.UI.HtmlControls.HtmlAnchor) this.FindControl("litBindPhone"); Regex regMobile = new Regex("^(13|14|15|17|18)\\d{9}$"); if (!regMobile.IsMatch(member.Username)) { this.litBindPhone.Visible = true; } else { this.litBindPhone.Visible = false; } if (this.litPoints != null) { this.litPoints.SetWhenIsNotNull(member.Points.ToString("F2")); } this.litMemberGrade = (System.Web.UI.WebControls.Literal) this.FindControl("litMemberGrade"); MemberGradeInfo memberGrade = MemberProcessor.GetMemberGrade(member.GradeId); if (memberGrade != null) { this.litMemberGrade.SetWhenIsNotNull(memberGrade.Name); } this.litUserName.Text = (string.IsNullOrEmpty(member.RealName) ? member.Username : member.RealName); this.litWaitForRecieveCount = (System.Web.UI.WebControls.Literal) this.FindControl("litWaitForRecieveCount"); this.litWaitForPayCount = (System.Web.UI.WebControls.Literal) this.FindControl("litWaitForPayCount"); OrderQuery orderQuery = new OrderQuery(); orderQuery.Status = OrderStatus.WaitBuyerPay; int userOrderCount = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery); // HttpCookie httpCookieMember = new HttpCookie("wait"); httpCookieMember.Value = userOrderCount.ToString(); httpCookieMember.Expires = System.DateTime.Now.AddYears(1); HttpContext.Current.Response.Cookies.Add(httpCookieMember); #region 处理cookie中的购物车和收藏信息 Member curMember = HiContext.Current.User as Member; if (curMember != null && !curMember.IsAnonymous) { //修改TopRegionId if (curMember.TopRegionId == 0) { long ip = 0; try { ip = Globals.IpToInt(Globals.IPAddress); } catch { } if (ip != 0) { string provinceName = TradeHelper.GetProvinceName(ip); int ProvinceId = 0; if (!string.IsNullOrEmpty(provinceName)) { provinceName = provinceName.Replace("市", ""); ProvinceId = RegionHelper.GetProvinceId(provinceName); ErrorLog.Write(string.Format("更新会员的ProvinceId:{0}", ProvinceId)); if (ProvinceId != 0) { UserHelper.UpdateUserTopRegionId(curMember.UserId, ProvinceId); } } } } // ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } System.Web.HttpCookie cookieFavorite = HiContext.Current.Context.Request.Cookies["Hid_Ecshop_Favorite_Data_New"]; if (cookieFavorite != null && !string.IsNullOrEmpty(cookieFavorite.Value)) { string[] favoriteProductIds = cookieFavorite.Value.Split('|'); int productId = 0; foreach (string fav in favoriteProductIds) { try { productId = int.Parse(fav); int favoriteId; ProductBrowser.AddProductToFavorite(productId, curMember.UserId, out favoriteId); } catch { continue; } } cookieFavorite.Expires = DateTime.Now.AddDays(-1); HttpContext.Current.Response.Cookies.Add(cookieFavorite); } } #endregion //购物车商品数量 ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); string quantity = "0"; if (shoppingCart != null) { quantity = shoppingCart.GetQuantity().ToString(); } HttpCookie httpCookieShoppingCart = new HttpCookie("cn"); httpCookieShoppingCart.Value = quantity; httpCookieShoppingCart.Expires = System.DateTime.Now.AddYears(1); HttpContext.Current.Response.Cookies.Add(httpCookieShoppingCart); this.litWaitForPayCount.SetWhenIsNotNull(userOrderCount.ToString()); orderQuery.Status = OrderStatus.SellerAlreadySent; userOrderCount = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery); this.litWaitForRecieveCount.SetWhenIsNotNull(userOrderCount.ToString()); // orderQuery.Status = OrderStatus.All; userOrderCount = MemberProcessor.GetUserOrderCount(HiContext.Current.User.UserId, orderQuery); this.litAllOrderCount.SetWhenIsNotNull(userOrderCount.ToString()); userOrderCount = MemberProcessor.GetRefundCount(HiContext.Current.User.UserId); this.litRefundCount.SetWhenIsNotNull(userOrderCount.ToString()); userOrderCount = MemberProcessor.GetReturnCount(HiContext.Current.User.UserId); this.litReturnCount.SetWhenIsNotNull(userOrderCount.ToString()); userOrderCount = MemberProcessor.GetReplaceCount(HiContext.Current.User.UserId); this.litReplaceCount.SetWhenIsNotNull(userOrderCount.ToString()); int UserNotReadCoupons = MemberProcessor.GetUserNotReadCoupons(HiContext.Current.User.UserId); this.litCoupons.SetWhenIsNotNull(UserNotReadCoupons.ToString()); int UserNotReadlitVoucher = MemberProcessor.GetUserNotReadVoucher(HiContext.Current.User.UserId); if (this.litVoucher != null) { this.litVoucher.SetWhenIsNotNull(UserNotReadlitVoucher.ToString()); } if (this.litUserLink != null) { System.Uri url = System.Web.HttpContext.Current.Request.Url; string text = (url.Port == 80) ? string.Empty : (":" + url.Port.ToString(System.Globalization.CultureInfo.InvariantCulture)); this.litUserLink.Text = string.Concat(new object[] { string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}://{1}{2}", new object[] { url.Scheme, url.Host, text }), Globals.ApplicationPath, "/VShop/?ReferralUserId=", HiContext.Current.User.UserId }); } if (this.referralLink != null) { this.referralLink.CssClass = "list-group-item"; if (member.ReferralStatus == 0 || member.ReferralStatus == 1 || member.ReferralStatus == 3) { this.referralLink.Text = "申请成为推广员"; if (member.ReferralStatus == 1 || member.ReferralStatus == 3) { this.referralLink.NavigateUrl = "/VShop/ReferralRegisterresults.aspx"; } else { this.referralLink.NavigateUrl = "/VShop/ReferralRegisterAgreement.aspx"; } } if (member.ReferralStatus == 2) { this.referralLink.Text = "推广员"; this.referralLink.NavigateUrl = "/VShop/Referral.aspx"; } } if (bindAccountLink != null) { this.bindAccountLink.CssClass = "list-group-item"; this.bindAccountLink.Text = "绑定PC端会员帐号"; this.bindAccountLink.NavigateUrl = "/VShop/BindPCAccount.aspx"; } int totalCount = 0; string opernId = member.OpenId; if (!string.IsNullOrEmpty(opernId)) { totalCount = UserHelper.GetToalCountByOpenId(opernId); } if (switchAccountLink != null && totalCount >= 2) { this.switchAccountLink.CssClass = "list-group-item"; this.switchAccountLink.Text = "切换帐号"; this.switchAccountLink.NavigateUrl = "/VShop/SwitchAccount.aspx"; } }
protected override void AttachChildControls() { this.litProductTotalPrice = (System.Web.UI.WebControls.Literal) this.FindControl("litProductTotalPrice"); this.litTotalTax = (System.Web.UI.WebControls.Literal) this.FindControl("litTotalTax"); this.listOrders = (EcShop.UI.SaleSystem.Tags.Common_CartSupplierProducts) this.FindControl("common_cartsupplierproducts"); this.listOrders.ItemDataBound += new EcShop.UI.SaleSystem.Tags.Common_CartSupplierProducts.DataBindEventHandler(this.listOrders_ItemDataBound); this.litTotal = (System.Web.UI.WebControls.Literal) this.FindControl("litTotal"); #region 处理cookie中的购物车和收藏信息 Member curMember = HiContext.Current.User as Member; if (curMember != null && !curMember.IsAnonymous) { ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } System.Web.HttpCookie cookieFavorite = HiContext.Current.Context.Request.Cookies["Hid_Ecshop_Favorite_Data_New"]; if (cookieFavorite != null && !string.IsNullOrEmpty(cookieFavorite.Value)) { string[] favoriteProductIds = cookieFavorite.Value.Split('|'); int productId = 0; foreach (string fav in favoriteProductIds) { try { productId = int.Parse(fav); int favoriteId; ProductBrowser.AddProductToFavorite(productId, curMember.UserId, out favoriteId); } catch { continue; } } cookieFavorite.Expires = DateTime.Now.AddDays(-1); HttpContext.Current.Response.Cookies.Add(cookieFavorite); } } #endregion ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); if (shoppingCart != null) { //foreach (ShoppingCartItemInfo item in shoppingCart.LineItems) //{ // item.TaxRate = Math.Round(item.TaxRate * 100, 0); //} IList <ShoppingCartItemInfo> list = shoppingCart.LineItems; IQueryable <ShoppingCartItemInfo> queryableList = new EnumerableQuery <ShoppingCartItemInfo>(list); var query = from q in queryableList group q by new { id = q.SupplierId } into q1 select new { SupplierId = q1.FirstOrDefault().SupplierId, //Amount = q1.Sum(x => x.SupplierId) SupplierName = q1.FirstOrDefault().SupplierName, SupplierLogo = q1.FirstOrDefault().Logo }; this.listOrders.DataSource = query; this.listOrders.DataBind(); this.litTotal.Text = shoppingCart.GetNewAmount().ToString("F2"); decimal totaltax = shoppingCart.CalTotalTax();// shoppingCart.CalTotalTax(); //this.litTotalTax.Text = (totaltax < 50 ? "0.00" : totaltax.ToString("F2")); if (totaltax <= 50) { this.litTotalTax.Text = string.Format("<span style='text-decoration: line-through;'>{0}</span>", totaltax.ToString("F2")); } else { this.litTotalTax.Text = string.Format("{0}", totaltax.ToString("F2")); } this.litProductTotalPrice.Text = shoppingCart.GetNewAmount().ToString("F2"); //shoppingCart.GetTotal().ToString("F2"); } HttpCookie httpCookieShoppingCart = new HttpCookie("cn"); string quantity = "0"; if (shoppingCart != null) { quantity = shoppingCart.GetQuantity().ToString(); } httpCookieShoppingCart.Value = quantity; httpCookieShoppingCart.Expires = System.DateTime.Now.AddYears(1); HttpContext.Current.Response.Cookies.Add(httpCookieShoppingCart); HttpCookie cookieSkuIds = this.Page.Request.Cookies["UserSession-SkuIds"]; if (cookieSkuIds != null) { cookieSkuIds.Expires = DateTime.Now.AddDays(-1); cookieSkuIds.Values.Clear(); HttpContext.Current.Response.AppendCookie(cookieSkuIds); } PageTitle.AddSiteNameTitle("购物车"); }
private void btnBindingLogin_Click(object sender, EventArgs e) { string text = Globals.StripAllTags(this.Parameters["CurrentOpenId"].ToNullString()); string text2 = Globals.StripAllTags(base.GetParameter("HIGW", false).ToNullString().Replace("_", ".")); if (this.Page.IsValid) { string text3 = Globals.StripAllTags(this.txtBindUserName.Text.Trim()); if (string.IsNullOrEmpty(text3)) { this.ShowMessage("用户名不能为空", false, "", 1); } else { MemberInfo memberInfo = MemberProcessor.ValidLogin(text3, this.txtBindPassword.Text); if (memberInfo != null) { if (!string.IsNullOrEmpty(memberInfo.UnionId) && text2.ToLower() == "hishop.plugins.openid.weixin.weixinservice" && memberInfo.UnionId != text) { this.ShowMessage("该用户已存在信任登录绑定关系,请选择其它帐号", false, "", 1); } else { MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId(text2, text); if (memberByOpenId != null && memberByOpenId.UserId != memberInfo.UserId) { this.ShowMessage("该用户已存在信任登录绑定关系,请选择其它帐号", false, "", 1); } else { if (string.IsNullOrEmpty(memberInfo.NickName)) { memberInfo.NickName = this.hidNickName.Value; MemberProcessor.UpdateMember(memberInfo); } Users.SetCurrentUser(memberInfo.UserId, 0, true, true); HiContext.Current.User = memberInfo; ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text)) { if (text2.ToLower() == "hishop.plugins.openid.weixin.weixinservice" && MemberProcessor.GetMemberByUnionId(text) == null) { memberInfo.UnionId = text; MemberProcessor.UpdateMember(memberInfo); } MemberOpenIdInfo memberOpenIdInfo = new MemberOpenIdInfo(); memberOpenIdInfo.UserId = memberInfo.UserId; memberOpenIdInfo.OpenIdType = text2; memberOpenIdInfo.OpenId = text; if (MemberProcessor.GetMemberByOpenId(memberOpenIdInfo.OpenIdType, memberOpenIdInfo.OpenId) == null) { MemberProcessor.AddMemberOpenId(memberOpenIdInfo); } } this.SetLoginState(memberInfo, 0); } } } else { this.ShowMessage("用户名或密码不正确", false, "", 1); } } } }
private void Notify_Authenticated(object sender, AuthenticatedEventArgs e) { HttpCookie cookie; string str2; this.parameters.Add("CurrentOpenId", e.OpenId); HiContext current = HiContext.Current; string usernameWithOpenId = UserHelper.GetUsernameWithOpenId(e.OpenId, this.openIdType); if (string.IsNullOrEmpty(usernameWithOpenId)) { string str3 = this.openIdType.ToLower(); if (str3 == null) { goto Label_024D; } if (!(str3 == "hishop.plugins.openid.alipay.alipayservice")) { if (str3 == "hishop.plugins.openid.qq.qqservice") { this.SkipQQOpenId(); goto Label_0267; } if (str3 == "hishop.plugins.openid.taobao.taobaoservice") { this.SkipTaoBaoOpenId(); goto Label_0267; } if (str3 == "hishop.plugins.openid.sina.sinaservice") { this.SkipSinaOpenId(); goto Label_0267; } goto Label_024D; } this.SkipAlipayOpenId(); goto Label_0267; } Member member = Users.GetUser(0, usernameWithOpenId, false, true) as Member; if (member == null) { base.Response.Write("登录失败,信任登录只能用于会员登录。"); return; } if (HiContext.Current.SiteSettings.IsDistributorSettings) { if (member.ParentUserId.HasValue) { if (member.ParentUserId.Value == HiContext.Current.SiteSettings.UserId) { goto Label_00FE; } } base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。"); return; } if (member.ParentUserId.HasValue && (member.ParentUserId.Value != 0)) { base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。"); return; } Label_00FE: cookie = FormsAuthentication.GetAuthCookie(member.Username, false); member.GetUserCookie().WriteCookie(cookie, 30, false); HiContext.Current.User = member; ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); CookieShoppingProvider.Instance().ClearShoppingCart(); current.User = member; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } if (!string.IsNullOrEmpty(this.parameters["token"])) { HttpCookie cookie3 = new HttpCookie("Token_" + HiContext.Current.User.UserId.ToString()); cookie3.Expires = DateTime.Now.AddMinutes(30.0); cookie3.Value = this.parameters["token"]; HttpContext.Current.Response.Cookies.Add(cookie3); } goto Label_0267; Label_024D: this.Page.Response.Redirect(Globals.GetSiteUrls().Home); Label_0267: str2 = this.parameters["HITO"]; if (str2 == "1") { this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder")); } else { this.Page.Response.Redirect(Globals.GetSiteUrls().Home); } }
protected int SkipWeixinOpenId(string openId, string weixinNickName, string unionId, string headimgurl, string ReferralUserId, bool isSubscribe) { int num = 1; MemberInfo memberInfo = MemberProcessor.GetMemberByOpenId("hishop.plugins.openid.weixin", openId); bool flag = false; if (memberInfo == null) { memberInfo = MemberProcessor.GetMemberByUnionId(unionId); flag = true; } SiteSettings masterSettings = SettingsManager.GetMasterSettings(); ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); bool flag2 = false; if (memberInfo != null) { num = 2; if (memberInfo.IsSubscribe != isSubscribe) { memberInfo.IsSubscribe = isSubscribe; flag2 = true; } bool flag3 = MemberProcessor.IsBindedWeixin(memberInfo.UserId, "hishop.plugins.openid.weixin"); memberInfo.Picture = headimgurl; if (!string.IsNullOrEmpty(unionId) && memberInfo.UnionId != unionId && !flag) { memberInfo.UnionId = unionId; flag2 = true; } if (flag) { if (!flag3) { MemberOpenIdInfo memberOpenIdInfo = new MemberOpenIdInfo(); memberOpenIdInfo.UserId = memberInfo.UserId; memberOpenIdInfo.OpenIdType = "hishop.plugins.openid.weixin"; memberOpenIdInfo.OpenId = openId; MemberProcessor.AddMemberOpenId(memberOpenIdInfo); memberInfo.IsQuickLogin = true; flag2 = true; } else { MemberOpenIdInfo memberOpenIdInfo2 = new MemberOpenIdInfo(); memberOpenIdInfo2.UserId = memberInfo.UserId; memberOpenIdInfo2.OpenIdType = "hishop.plugins.openid.weixin"; memberOpenIdInfo2.OpenId = openId; MemberProcessor.UpdateMemberOpenId(memberOpenIdInfo2); } } if (flag2) { MemberProcessor.UpdateMember(memberInfo); } Users.SetCurrentUser(memberInfo.UserId, 30, true, false); HiContext.Current.User = memberInfo; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(openId)) { HttpCookie httpCookie = new HttpCookie("openId"); httpCookie.HttpOnly = true; httpCookie.Value = openId; httpCookie.Expires = DateTime.MaxValue; HttpContext.Current.Response.Cookies.Add(httpCookie); } lock (this.lockCopyRedEnvelope) { this.CopyRedEnvelope(openId, memberInfo); } return(num); } memberInfo = new MemberInfo(); memberInfo.Picture = headimgurl; memberInfo.IsSubscribe = isSubscribe; int num2 = 0; if (ReferralUserId.ToInt(0) > 0) { memberInfo.ReferralUserId = ReferralUserId.ToInt(0); } MemberWXReferralInfo wXReferral = VShopHelper.GetWXReferral(openId.Trim()); if (wXReferral != null) { VShopHelper.DeleteWXReferral(openId.Trim()); } memberInfo.GradeId = MemberProcessor.GetDefaultMemberGrade(); if (!string.IsNullOrEmpty(weixinNickName)) { MemberInfo memberInfo2 = memberInfo; MemberInfo memberInfo3 = memberInfo; string text3 = memberInfo2.UserName = (memberInfo3.NickName = HttpUtility.UrlDecode(weixinNickName)); } if (string.IsNullOrEmpty(memberInfo.UserName)) { memberInfo.UserName = "******" + this.GenerateUsername(8); } if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null) { memberInfo.UserName = "******" + this.GenerateUsername(9); if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null) { memberInfo.UserName = this.GenerateUsername(); if (MemberProcessor.FindMemberByUsername(memberInfo.UserName) != null) { num = -1; } } } if (num == 1) { string text4 = this.GeneratePassword(); string text5 = "Open"; string text6 = text4; text4 = (memberInfo.Password = Users.EncodePassword(text4, text5)); memberInfo.PasswordSalt = text5; memberInfo.RegisteredSource = 3; memberInfo.CreateDate = DateTime.Now; memberInfo.IsQuickLogin = true; memberInfo.IsLogined = true; memberInfo.UnionId = unionId; num2 = MemberProcessor.CreateMember(memberInfo); if (num2 <= 0) { num = -1; } } if (num == 1) { memberInfo.UserId = num2; memberInfo.UserName = MemberHelper.GetUserName(memberInfo.UserId); MemberHelper.Update(memberInfo, true); Users.SetCurrentUser(memberInfo.UserId, 30, false, false); HiContext.Current.User = memberInfo; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(openId)) { MemberOpenIdInfo memberOpenIdInfo3 = new MemberOpenIdInfo(); memberOpenIdInfo3.UserId = memberInfo.UserId; memberOpenIdInfo3.OpenIdType = "hishop.plugins.openid.weixin"; memberOpenIdInfo3.OpenId = openId; if (MemberProcessor.GetMemberByOpenId(memberOpenIdInfo3.OpenIdType, openId) == null) { MemberProcessor.AddMemberOpenId(memberOpenIdInfo3); } if (!string.IsNullOrEmpty(openId)) { HttpCookie httpCookie2 = new HttpCookie("openId"); httpCookie2.HttpOnly = true; httpCookie2.Value = openId; httpCookie2.Expires = DateTime.MaxValue; HttpContext.Current.Response.Cookies.Add(httpCookie2); } lock (this.lockCopyRedEnvelope) { this.CopyRedEnvelope(openId, memberInfo); } } } return(num); }
private void Notify_Authenticated(object sender, AuthenticatedEventArgs e) { string str; parameters.Add("CurrentOpenId", e.OpenId); HiContext current = HiContext.Current; string usernameWithOpenId = UserHelper.GetUsernameWithOpenId(e.OpenId, openIdType); if (!string.IsNullOrEmpty(usernameWithOpenId)) { IUser user = Users.GetUser(0, usernameWithOpenId, false, true); if (((user == null) || user.IsAnonymous) || (user.UserRole == UserRole.SiteManager)) { Response.Write("登录失败,信任登录只能用于会员登录。"); return; } if (user.IsLockedOut) { Response.Write("登录失败,您的用户账号还在等待审核。"); return; } HttpCookie authCookie = FormsAuthentication.GetAuthCookie(user.Username, false); user.GetUserCookie().WriteCookie(authCookie, 30, false); HiContext.Current.User = user; ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); CookieShoppingProvider.Instance().ClearShoppingCart(); current.User = user; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } if (!string.IsNullOrEmpty(parameters["token"])) { HttpCookie cookie3 = new HttpCookie("Token_" + HiContext.Current.User.UserId.ToString()); cookie3.Expires = DateTime.Now.AddMinutes(30.0); cookie3.Value = parameters["token"]; HttpCookie cookie = cookie3; HttpContext.Current.Response.Cookies.Add(cookie); } goto Label_0214; } string str3 = openIdType.ToLower(); if (str3 == null) { goto Label_01F9; } if (!(str3 == "hishop.plugins.openid.alipay.alipayservice")) { if (!(str3 == "hishop.plugins.openid.qq.qqservice")) { goto Label_01F9; } SkipQQOpenId(); } else { SkipAlipayOpenId(); } goto Label_0214; Label_01F9: Page.Response.Redirect(Globals.GetSiteUrls().Home); Label_0214: str = parameters["HITO"]; if (str == "1") { Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("submitOrder")); } else { Page.Response.Redirect(Globals.GetSiteUrls().Home); } }
private void Notify_Authenticated(object sender, AuthenticatedEventArgs e) { this.parameters.Add("CurrentOpenId", e.OpenId); HiContext current = HiContext.Current; MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId(this.openIdType, e.OpenId); if (memberByOpenId != null) { Users.SetCurrentUser(memberByOpenId.UserId, 30, true, false); HiContext.Current.User = memberByOpenId; ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(this.parameters["token"])) { HttpCookie httpCookie = new HttpCookie("Token_" + memberByOpenId.UserId); httpCookie.HttpOnly = true; httpCookie.Expires = DateTime.Now.AddMinutes(30.0); httpCookie.Value = this.parameters["token"]; HttpContext.Current.Response.Cookies.Add(httpCookie); } } else { switch (this.openIdType.ToLower()) { case "hishop.plugins.openid.alipay.alipayservice": this.SkipAlipayOpenId(); break; case "hishop.plugins.openid.qq.qqservice": this.SkipQQOpenId(); break; case "hishop.plugins.openid.taobao.taobaoservice": this.SkipTaoBaoOpenId(); break; case "hishop.plugins.openid.sina.sinaservice": this.SkipSinaOpenId(); break; default: this.Page.Response.Redirect("/"); break; } } string a = this.parameters["HITO"]; if (a == "1") { this.Page.Response.Redirect("/SubmmitOrder"); } else { this.Page.Response.Redirect("/"); } }
protected void SkipQQOpenId() { Hidistro.Membership.Context.Member member; if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings) { member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Underling); member.ParentUserId = Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId; } else { member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Member); } if (Hidistro.Membership.Context.HiContext.Current.ReferralUserId > 0) { member.ReferralUserId = new int?(Hidistro.Membership.Context.HiContext.Current.ReferralUserId); } member.GradeId = MemberProcessor.GetDefaultMemberGrade(); System.Web.HttpCookie httpCookie = System.Web.HttpContext.Current.Request.Cookies["NickName"]; if (httpCookie != null) { member.Username = System.Web.HttpUtility.UrlDecode(httpCookie.Value); } if (string.IsNullOrEmpty(member.Username)) { member.Username = "******" + this.GenerateUsername(8); } member.Email = this.GenerateUsername() + "@localhost.com"; string text = this.GeneratePassword(); member.Password = text; member.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed; member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed; member.TradePassword = text; member.IsApproved = true; member.RealName = string.Empty; member.Address = string.Empty; if (MemberProcessor.CreateMember(member) != Hidistro.Membership.Core.Enums.CreateUserStatus.Created) { member.Username = "******" + this.GenerateUsername(8); member.Password = (member.TradePassword = text); if (MemberProcessor.CreateMember(member) != Hidistro.Membership.Core.Enums.CreateUserStatus.Created) { member.Username = this.GenerateUsername(); member.Email = this.GenerateUsername() + "@localhost.com"; member.Password = (member.TradePassword = text); if (MemberProcessor.CreateMember(member) != Hidistro.Membership.Core.Enums.CreateUserStatus.Created) { base.Response.Write("为您创建随机账户时失败,请重试。"); return; } } } Hidistro.Membership.Core.UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]); 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(); cookieShoppingProvider.ClearShoppingCart(); Hidistro.Membership.Context.HiContext.Current.User = member; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } if (!string.IsNullOrEmpty(this.parameters["token"])) { System.Web.HttpCookie httpCookie2 = new System.Web.HttpCookie("Token_" + Hidistro.Membership.Context.HiContext.Current.User.UserId.ToString()); httpCookie2.Expires = System.DateTime.Now.AddMinutes(30.0); httpCookie2.Value = this.parameters["token"]; System.Web.HttpContext.Current.Response.Cookies.Add(httpCookie2); } if (!string.IsNullOrEmpty(this.parameters["target_url"])) { this.Page.Response.Redirect(this.parameters["target_url"]); } this.Page.Response.Redirect(Globals.GetSiteUrls().Home); }
private void Login() { string userid = Request["userid"]; string userdata = Request["userdata"]; string timestamp = Request["timestamp"]; string source = Request["source"]; if (string.IsNullOrWhiteSpace(userid) || string.IsNullOrWhiteSpace(userdata) || string.IsNullOrWhiteSpace(timestamp) || string.IsNullOrWhiteSpace(source)) { Response.Write("fail,缺少必要参数"); Response.End(); } string key = ConfigurationManager.AppSettings["Key_CCB"]; string iv = ConfigurationManager.AppSettings["IV_CCB"]; string dataKey = Cryptographer.DESDecrypt(userdata, key, iv); string deUserId = Cryptographer.DESDecrypt(userid, dataKey, iv); string deTimestamp = Cryptographer.DESDecrypt(timestamp, dataKey, iv); if (string.IsNullOrWhiteSpace(dataKey) || string.IsNullOrWhiteSpace(deUserId) || string.IsNullOrWhiteSpace(deTimestamp)) { Response.Write("fail,请求参数无效"); Response.End(); } DateTime time = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Add(new TimeSpan(long.Parse(deTimestamp + "0000000"))); TimeSpan span = DateTime.Now - time; if (span.TotalSeconds > 60) { Response.Write("fail,请求已过期"); Response.End(); } Member member = Users.GetUserByCcbOpenId(deUserId) as Member; if (member == null) { // fail,返回原因 Response.Write("fail,用户不存在"); Response.End(); } System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false); IUserCookie userCookie = member.GetUserCookie(); userCookie.WriteCookie(authCookie, 30, false); ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); HiContext.Current.User = member; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } // 登录成功跳转到海美生活用户中心 Response.Redirect("/User/UserDefault.aspx"); }
protected void SkipTaoBaoOpenId() { Member member = null; if (HiContext.Current.SiteSettings.IsDistributorSettings) { member = new Member(UserRole.Underling); member.ParentUserId = HiContext.Current.SiteSettings.UserId; } else { member = new Member(UserRole.Member); } if (HiContext.Current.ReferralUserId > 0) { member.ReferralUserId = new int?(HiContext.Current.ReferralUserId); } member.GradeId = MemberProcessor.GetDefaultMemberGrade(); string str = this.parameters["CurrentOpenId"]; if (!string.IsNullOrEmpty(str)) { member.Username = HttpUtility.UrlDecode(str); } if (string.IsNullOrEmpty(member.Username)) { member.Username = "******" + this.GenerateUsername(8); } member.Email = this.GenerateUsername() + "@localhost.com"; if (string.IsNullOrEmpty(member.Email)) { member.Email = this.GenerateUsername() + "@localhost.com"; } string str2 = this.GeneratePassword(); member.Password = str2; member.PasswordFormat = MembershipPasswordFormat.Hashed; member.TradePasswordFormat = MembershipPasswordFormat.Hashed; member.TradePassword = str2; member.IsApproved = true; member.RealName = string.Empty; member.Address = string.Empty; if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created) { member.Username = "******" + this.GenerateUsername(8); member.Password = member.TradePassword = str2; if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created) { member.Username = this.GenerateUsername(); member.Email = this.GenerateUsername() + "@localhost.com"; member.Password = member.TradePassword = str2; if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created) { base.Response.Write("为您创建随机账户时失败,请重试。"); return; } } } UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]); HttpCookie authCookie = FormsAuthentication.GetAuthCookie(member.Username, false); member.GetUserCookie().WriteCookie(authCookie, 30, false); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); CookieShoppingProvider.Instance().ClearShoppingCart(); HiContext.Current.User = member; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } if (!string.IsNullOrEmpty(this.parameters["token"])) { HttpCookie cookie = new HttpCookie("Token_" + HiContext.Current.User.UserId.ToString()); cookie.Expires = DateTime.Now.AddMinutes(30.0); cookie.Value = this.parameters["token"]; HttpContext.Current.Response.Cookies.Add(cookie); } if (!string.IsNullOrEmpty(this.parameters["target_url"])) { this.Page.Response.Redirect(this.parameters["target_url"]); } this.Page.Response.Redirect(Globals.GetSiteUrls().Home); }
protected void SkipSinaOpenId() { Member member = new Member(UserRole.Member); if (HiContext.Current.ReferralUserId > 0) { member.ReferralUserId = new int?(HiContext.Current.ReferralUserId); } member.GradeId = MemberProcessor.GetDefaultMemberGrade(); member.Username = this.parameters["CurrentOpenId"]; if (string.IsNullOrEmpty(member.Username)) { member.Username = "******" + this.GenerateUsername(8); } member.Email = this.GenerateUsername() + "@localhost.com"; string text = this.GeneratePassword(); member.Password = text; member.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed; member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed; member.TradePassword = text; member.IsApproved = true; member.RealName = string.Empty; member.Address = string.Empty; if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created) { member.Username = "******" + this.GenerateUsername(9); member.Password = (member.TradePassword = text); if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created) { member.Username = this.GenerateUsername(); member.Email = this.GenerateUsername() + "@localhost.com"; member.Password = (member.TradePassword = text); if (MemberProcessor.CreateMember(member) != CreateUserStatus.Created) { base.Response.Write("为您创建随机账户时失败,请重试。"); return; } } } UserHelper.BindOpenId(member.Username, this.parameters["CurrentOpenId"], this.parameters["HIGW"]); System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false); IUserCookie userCookie = member.GetUserCookie(); userCookie.WriteCookie(authCookie, 30, false); ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); HiContext.Current.User = member; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(this.parameters["token"])) { System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + 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); } this.Page.Response.Redirect(Globals.GetSiteUrls().Home); }
void btnRegister_Click(object sender, EventArgs e) { if (!this.chkAgree.Checked) { this.ShowMessage("您必须先阅读并同意注册协议", false); } else if (string.Compare(this.txtUserName.Text.Trim().ToLower(CultureInfo.InvariantCulture), "anonymous", false, CultureInfo.InvariantCulture) == 0) { this.ShowMessage("已经存在相同的用户名", false); } else { string pattern = @"[\u4e00-\u9fa5a-zA-Z]+[\u4e00-\u9fa5_a-zA-Z0-9]*"; Regex regex = new Regex(pattern); if ((!regex.IsMatch(this.txtUserName.Text.Trim()) || (this.txtUserName.Text.Trim().Length < 2)) || (this.txtUserName.Text.Trim().Length > 20)) { this.ShowMessage("用户名不能为空,必须以汉字或是字母开头,且在2-20个字符之间", false); } else if (string.Compare(this.txtPassword.Text, this.txtPassword2.Text) != 0) { this.ShowMessage("两次输入的密码不相同", false); } else if (this.txtPassword.Text.Length == 0) { this.ShowMessage("密码不能为空", false); } else if ((this.txtPassword.Text.Length < Membership.Provider.MinRequiredPasswordLength) || (this.txtPassword.Text.Length > HiConfiguration.GetConfig().PasswordMaxLength)) { this.ShowMessage(string.Format("密码的长度只能在{0}和{1}个字符之间", Membership.Provider.MinRequiredPasswordLength, HiConfiguration.GetConfig().PasswordMaxLength), false); } else { Member member = null; if (HiContext.Current.SiteSettings.IsDistributorSettings) { member = new Member(UserRole.Underling); member.ParentUserId = HiContext.Current.SiteSettings.UserId; } else { member = new Member(UserRole.Member); } if (HiContext.Current.ReferralUserId > 0) { member.ReferralUserId = new int?(HiContext.Current.ReferralUserId); } member.GradeId = MemberProcessor.GetDefaultMemberGrade(); member.Username = Globals.HtmlEncode(this.txtUserName.Text.Trim()); member.Email = this.txtEmail.Text; member.Password = this.txtPassword.Text; member.PasswordFormat = MembershipPasswordFormat.Hashed; member.TradePasswordFormat = MembershipPasswordFormat.Hashed; member.TradePassword = this.txtPassword.Text; member.IsApproved = true; member.RealName = string.Empty; member.Address = string.Empty; if (this.ValidationMember(member)) { if (!HiContext.Current.CheckVerifyCode(this.txtNumber.Text)) { this.ShowMessage("验证码输入错误", false); } else { switch (MemberProcessor.CreateMember(member)) { case CreateUserStatus.UnknownFailure: this.ShowMessage("未知错误", false); return; case CreateUserStatus.Created: { Messenger.UserRegister(member, this.txtPassword.Text); member.OnRegister(new UserEventArgs(member.Username, this.txtPassword.Text, null)); IUser user = Users.GetUser(0, member.Username, false, true); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); CookieShoppingProvider.Instance().ClearShoppingCart(); HiContext.Current.User = user; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } HttpCookie authCookie = FormsAuthentication.GetAuthCookie(member.Username, false); user.GetUserCookie().WriteCookie(authCookie, 30, false); this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("registerUserSave") + "?UserId=" + user.UserId); return; } case CreateUserStatus.DuplicateUsername: this.ShowMessage("已经存在相同的用户名", false); return; case CreateUserStatus.DuplicateEmailAddress: this.ShowMessage("电子邮件地址已经存在", false); return; case CreateUserStatus.InvalidFirstCharacter: case CreateUserStatus.Updated: case CreateUserStatus.Deleted: case CreateUserStatus.InvalidQuestionAnswer: return; case CreateUserStatus.DisallowedUsername: this.ShowMessage("用户名禁止注册", false); return; case CreateUserStatus.InvalidPassword: this.ShowMessage("无效的密码", false); return; case CreateUserStatus.InvalidEmail: this.ShowMessage("无效的电子邮件地址", false); return; } } } } } }
private void Notify_Authenticated(object sender, AuthenticatedEventArgs e) { this.parameters.Add("CurrentOpenId", e.OpenId); HiContext current = HiContext.Current; string usernameWithOpenId = UserHelper.GetUsernameWithOpenId(e.OpenId, this.openIdType); if (!string.IsNullOrEmpty(usernameWithOpenId)) { Member member = Users.GetUser(0, usernameWithOpenId, false, true) as Member; if (member == null) { base.Response.Write("登录失败,信任登录只能用于会员登录。"); return; } if (member.ParentUserId.HasValue && member.ParentUserId.Value != 0) { base.Response.Write("账号已经与本平台的其它子站绑定,不能在此域名上登录。"); return; } System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false); IUserCookie userCookie = member.GetUserCookie(); userCookie.WriteCookie(authCookie, 30, false); HiContext.Current.User = member; ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); current.User = member; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(this.parameters["token"])) { System.Web.HttpCookie httpCookie = new System.Web.HttpCookie("Token_" + 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 == "Ecdev.plugins.openid.alipay.alipayservice") { this.SkipAlipayOpenId(); goto IL_1EF; } if (a == "Ecdev.plugins.openid.qq.qqservice") { this.SkipQQOpenId(); goto IL_1EF; } if (a == "Ecdev.plugins.openid.taobao.taobaoservice") { this.SkipTaoBaoOpenId(); goto IL_1EF; } if (a == "Ecdev.plugins.openid.sina.sinaservice") { this.SkipSinaOpenId(); goto IL_1EF; } } this.Page.Response.Redirect(Globals.GetSiteUrls().Home); } IL_1EF: 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); }
private void SetLoginState(MemberInfo member, int iSendCouponCount = 0) { string text = Globals.StripAllTags(this.Parameters["CurrentOpenId"]); if (!string.IsNullOrEmpty(text)) { MemberOpenIdInfo memberOpenIdInfo = MemberProcessor.GetMemberOpenIdInfo(member.UserId, this.openIdType); if (memberOpenIdInfo != null && memberOpenIdInfo.OpenId != text) { this.ShowMessage("该账号已被绑定,请绑定其他帐号。", false, "", 1); return; } MemberOpenIdInfo memberOpenId = MemberProcessor.GetMemberOpenId(this.openIdType, text); if (memberOpenId == null) { memberOpenId = new MemberOpenIdInfo(); memberOpenId.UserId = member.UserId; memberOpenId.OpenIdType = this.openIdType; memberOpenId.OpenId = text; try { MemberProcessor.AddMemberOpenId(memberOpenId); } catch (Exception ex) { NameValueCollection param = new NameValueCollection { this.Page.Request.QueryString, this.Page.Request.Form }; Globals.WriteExceptionLog_Page(ex, param, "AddMemberOpenId"); } } } Users.SetCurrentUser(member.UserId, 0, true, true); HiContext.Current.User = member; ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(this.Parameters["token"])) { HttpCookie httpCookie = new HttpCookie("Token_" + member.UserId); httpCookie.HttpOnly = true; httpCookie.Expires = DateTime.Now.AddMinutes(30.0); httpCookie.Value = this.Parameters["token"]; HttpContext.Current.Response.Cookies.Add(httpCookie); } if (!string.IsNullOrEmpty(this.Parameters["target_url"])) { this.Page.Response.Redirect(this.Parameters["target_url"], true); } string text2 = this.Parameters["HITO"]; string text3 = this.Parameters["target_url"].ToNullString(); if (string.IsNullOrEmpty(text3)) { text3 = "/Default"; } if (iSendCouponCount > 0) { this.ShowMessage("恭喜您注册成功," + iSendCouponCount + " 张优惠券已经放入您的账户,可在会员中心我的优惠券中进行查看", true, text3, 1); } else { this.ShowMessage("恭喜您注册/登录成功", true, text3, 1); } }
private void btnRegister_Click(object sender, System.EventArgs e) { if (!this.chkAgree.Checked) { this.ShowMessage("您必须先阅读并同意注册协议", false); } else { if (string.Compare(this.txtUserName.Text.Trim().ToLower(System.Globalization.CultureInfo.InvariantCulture), "anonymous", false, System.Globalization.CultureInfo.InvariantCulture) == 0) { this.ShowMessage("已经存在相同的用户名", false); } else { if (this.txtUserName.Text.Trim().Length < 2 || this.txtUserName.Text.Trim().Length > 20) { this.ShowMessage("用户名不能为空,且在2-20个字符之间", false); } else { if (string.Compare(this.txtPassword.Text, this.txtPassword2.Text) != 0) { this.ShowMessage("两次输入的密码不相同", false); } else { if (this.txtPassword.Text.Length == 0) { this.ShowMessage("密码不能为空", false); } else { if (this.txtPassword.Text.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength || this.txtPassword.Text.Length > HiConfiguration.GetConfig().PasswordMaxLength) { this.ShowMessage(string.Format("密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, HiConfiguration.GetConfig().PasswordMaxLength), false); } else { Hidistro.Membership.Context.Member member; if (Hidistro.Membership.Context.HiContext.Current.SiteSettings.IsDistributorSettings) { member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Underling); member.ParentUserId = Hidistro.Membership.Context.HiContext.Current.SiteSettings.UserId; } else { member = new Hidistro.Membership.Context.Member(Hidistro.Membership.Core.Enums.UserRole.Member); } if (Hidistro.Membership.Context.HiContext.Current.ReferralUserId > 0) { member.ReferralUserId = new int?(Hidistro.Membership.Context.HiContext.Current.ReferralUserId); } member.GradeId = MemberProcessor.GetDefaultMemberGrade(); member.Username = Globals.HtmlEncode(this.txtUserName.Text.Trim()); member.Email = this.txtEmail.Text; member.Password = this.txtPassword.Text; member.PasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed; member.TradePasswordFormat = System.Web.Security.MembershipPasswordFormat.Hashed; member.TradePassword = this.txtPassword.Text; if (this.txtCellPhone != null) { member.CellPhone = this.txtCellPhone.Text; } member.IsApproved = true; member.RealName = string.Empty; member.Address = string.Empty; if (this.ValidationMember(member)) { if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtNumber.Text)) { this.ShowMessage("验证码输入错误", false); } else { switch (MemberProcessor.CreateMember(member)) { case Hidistro.Membership.Core.Enums.CreateUserStatus.UnknownFailure: this.ShowMessage("未知错误", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.Created: { Messenger.UserRegister(member, this.txtPassword.Text); member.OnRegister(new Hidistro.Membership.Context.UserEventArgs(member.Username, this.txtPassword.Text, null)); Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(0, member.Username, false, true); ShoppingCartInfo shoppingCart = ShoppingCartProcessor.GetShoppingCart(); CookieShoppingProvider cookieShoppingProvider = CookieShoppingProvider.Instance(); cookieShoppingProvider.ClearShoppingCart(); Hidistro.Membership.Context.HiContext.Current.User = user; if (shoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(shoppingCart); } System.Web.HttpCookie authCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(member.Username, false); Hidistro.Membership.Core.IUserCookie userCookie = user.GetUserCookie(); userCookie.WriteCookie(authCookie, 30, false); this.Page.Response.Redirect(Globals.GetSiteUrls().UrlData.FormatUrl("registerUserSave") + "?UserId=" + user.UserId); break; } case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateUsername: this.ShowMessage("已经存在相同的用户名", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.DuplicateEmailAddress: this.ShowMessage("电子邮件地址已经存在", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.DisallowedUsername: this.ShowMessage("用户名禁止注册", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidPassword: this.ShowMessage("无效的密码", false); break; case Hidistro.Membership.Core.Enums.CreateUserStatus.InvalidEmail: this.ShowMessage("无效的电子邮件地址", false); break; } } } } } } } } } }
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); }
private void Notify_Authenticated(object sender, AuthenticatedEventArgs e) { bool flag = false; if (this.hidToken != null) { this.hidToken.Value = Globals.StripAllTags(this.parameters["token"]); } if (this.hidUserId != null) { this.hidUserId.Value = Globals.StripAllTags(this.parameters["user_id"]); } if (this.hidEmail != null) { this.hidEmail.Value = Globals.StripAllTags(this.parameters["email"]); } string text = ""; switch (this.openIdType.ToLower()) { case "hishop.plugins.openid.alipay.alipayservice": text = (string.IsNullOrEmpty(this.parameters["real_name"]) ? string.Empty : this.parameters["real_name"].ToNullString().Trim()); break; case "hishop.plugins.openid.qq.qqservice": { HttpCookie httpCookie3 = HttpContext.Current.Request.Cookies["NickName"]; if (httpCookie3 != null) { text = HttpUtility.UrlDecode(httpCookie3.Value).Trim(); } break; } case "hishop.plugins.openid.taobao.taobaoservice": { HttpCookie httpCookie4 = HttpContext.Current.Request.Cookies["NickName"]; if (httpCookie4 != null) { text = HttpUtility.UrlDecode(httpCookie4.Value).Trim(); } break; } case "hishop.plugins.openid.sina.sinaservice": { HttpCookie httpCookie2 = HttpContext.Current.Request.Cookies["SinaNickName"]; if (httpCookie2 != null) { text = HttpUtility.UrlDecode(httpCookie2.Value).Trim(); } break; } case "hishop.plugins.openid.weixin.weixinservice": { HttpCookie httpCookie = HttpContext.Current.Request.Cookies["NickName"]; if (text != null) { text = HttpUtility.UrlDecode(httpCookie.Value).Trim(); } break; } default: this.Page.Response.Redirect("/", true); break; } this.hidRealName.Value = text; this.labNickName.Text = text; this.labNickName1.Text = text; this.labNickName2.Text = text; string text2 = this.Page.Request.QueryString["headimage"].ToNullString(); if (string.IsNullOrEmpty(text2)) { text2 = "/Templates/common/images/headerimg.png"; } this.userPicture.Src = text2; this.parameters.Add("CurrentOpenId", e.OpenId); HiContext current = HiContext.Current; this.openId = e.OpenId; if (!string.IsNullOrEmpty(this.openId)) { HttpCookie httpCookie5 = new HttpCookie("openId"); httpCookie5.HttpOnly = true; httpCookie5.Value = this.openId; httpCookie5.Expires = DateTime.MaxValue; HttpContext.Current.Response.Cookies.Add(httpCookie5); } MemberInfo memberByOpenId = MemberProcessor.GetMemberByOpenId(this.openIdType, this.openId); if (memberByOpenId != null) { Users.SetCurrentUser(memberByOpenId.UserId, 1, true, false); ShoppingCartInfo cookieShoppingCart = ShoppingCartProcessor.GetCookieShoppingCart(); current.User = memberByOpenId; if (cookieShoppingCart != null) { ShoppingCartProcessor.ConvertShoppingCartToDataBase(cookieShoppingCart); ShoppingCartProcessor.ClearCookieShoppingCart(); } if (!string.IsNullOrEmpty(this.parameters["token"])) { HttpCookie httpCookie6 = new HttpCookie("Token_" + HiContext.Current.UserId.ToString()); httpCookie6.HttpOnly = true; httpCookie6.Expires = DateTime.Now.AddMinutes(30.0); httpCookie6.Value = Globals.StripAllTags(this.parameters["token"]); HttpContext.Current.Response.Cookies.Add(httpCookie6); } } else { this.AuthMsg = "Auth_Sucess"; } }