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 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); }
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) { 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 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); }
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 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); 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); }
protected void SkipSinaOpenId() { 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 = 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) != Hidistro.Membership.Core.Enums.CreateUserStatus.Created) { member.Username = "******" + this.GenerateUsername(9); 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 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); } this.Page.Response.Redirect(Globals.GetSiteUrls().Home); }