void Login1_LoggedIn(object sender, EventArgs e) { if (IsCaptchaValid && Page.IsValid && IsPostBack) { MembershipUser user = Membership.GetUser(Login1.UserName); SueetieUser sueetieUser = SueetieUsers.GetUser(user.UserName); bool hasIP = String.IsNullOrEmpty(sueetieUser.IP); string ip = String.IsNullOrEmpty(sueetieUser.IP) ? HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] : sueetieUser.IP; if (SueetieUsers.IsIPBanned(ip)) { Response.Redirect("/members/message.aspx?msgid=9"); } else { SueetieUsers.CreateUpdateUserProfileCookie(sueetieUser); SueetieLogs.LogUserEntry(UserLogCategoryType.LoggedIn, -1, sueetieUser.UserID); sueetieUser.IP = ip; SueetieUsers.UpdateSueetieUserIP(sueetieUser); string returnUrl = Request.QueryString["ReturnUrl"]; if (returnUrl != null) { Response.Redirect(returnUrl); } else { Response.Redirect("/default.aspx", true); } } } }
protected void Page_Load(object sender, EventArgs e) { MembershipUser user; string username = Request.QueryString["uname"]; string valBinary = Request.QueryString["key"]; int userid = DataHelper.GetIntFromQueryString("uid", -1); if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(valBinary) && userid > 0) { user = Membership.GetUser(username); SueetieUser sueetieUser = SueetieUsers.GetUser(username); if ((user.IsApproved == false) && (valBinary == user.CreationDate.ToBinary().ToString()) && !sueetieUser.IsBanned) { user.IsApproved = true; Membership.UpdateUser(user); SueetieUsers.CreateUpdateUserProfileCookie(sueetieUser); SueetieLogs.LogUserEntry(UserLogCategoryType.JoinedCommunity, -1, userid); phActivated.Visible = true; phNot.Visible = false; } else { phActivated.Visible = false; phNot.Visible = true; } } else { phActivated.Visible = false; phNot.Visible = true; } }
protected void CreateUser_Click(object sender, System.EventArgs e) { if (txtDisplayName.Text.Trim().Length < 2) { labelUserMessage.Text = SueetieLocalizer.GetString("register_validator_displayname"); InitializeCaptcha(); return; } if (!SueetieUsers.IsNewDisplayName(txtDisplayName.Text)) { labelUserMessage.Text = string.Format(SueetieLocalizer.GetString("register_exists_displayname_long")); InitializeCaptcha(); return; } string ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; if (SueetieUsers.IsIPBanned(ip)) { MailMessage msg = new MailMessage(); msg.From = new MailAddress(SiteSettings.Instance.FromEmail, SiteSettings.Instance.FromName); MailAddress userAddress = new MailAddress(SiteSettings.Instance.ContactEmail, SiteSettings.Instance.SiteName + SueetieLocalizer.GetString("register_emailtoadmin_admin")); msg.To.Add(userAddress); msg.Subject = SueetieLocalizer.GetString("register_bannedattempt_subject"); string body = SueetieLocalizer.GetString("register_bannedattempt_firstline"); body += Environment.NewLine + Environment.NewLine; body += SueetieLocalizer.GetString("register_bannedattempt_ipaddress") + ip; body += SueetieLocalizer.GetString("register_bannedattempt_user") + txtUsername.Text + " (" + txtDisplayName.Text + ") " + txtEmailAddress.Text; body += Environment.NewLine + Environment.NewLine; msg.Body = body; if (SueetieConfiguration.Get().Core.SendEmails) { EmailHelper.AsyncSendEmail(msg); } Response.Redirect("/members/message.aspx?msgid=8"); return; } if (!IsCaptchaValid || !Page.IsValid || !IsPostBack) { return; } if (Membership.GetUser(txtUsername.Text) != null || Membership.GetUserNameByEmail(txtEmailAddress.Text) != null) { string loginUrl = "/members/login.aspx"; if (Request.QueryString["ReturnUrl"] != null) { loginUrl += "?ReturnUrl=" + Request.QueryString["ReturnUrl"]; } if (Membership.GetUser(txtUsername.Text) != null) { labelUserMessage.Text = string.Format(SueetieLocalizer.GetString("register_exists_username_long"), SiteSettings.Instance.SiteName, loginUrl); InitializeCaptcha(); } else if (Membership.GetUserNameByEmail(txtEmailAddress.Text) != null) { labelUserMessage.Text = string.Format(SueetieLocalizer.GetString("register_exists_email_long"), SiteSettings.Instance.SiteName, loginUrl); InitializeCaptcha(); } return; } if (registrationType == SueetieRegistrationType.Automatic) { FormsAuthentication.SetAuthCookie(txtUsername.Text, true); } var user = Membership.CreateUser(txtUsername.Text, txtPassword1.Text, txtEmailAddress.Text); if (registrationType != SueetieRegistrationType.Automatic) { user.IsApproved = false; Membership.UpdateUser(user); } ProfileBase profile = (ProfileBase)SueetieUserProfile.Create(txtUsername.Text, true); profile["DisplayName"] = txtDisplayName.Text; if (chkNewsletter != null) { profile["Newsletter"] = chkNewsletter.Checked; } profile.Save(); // SUEETIE NOTE: [BLOG] BlogEngine.NET will throw an error if authorizing a user and they do not appear in be_User table. // When Blog Application added, uncomment these lines. try { beDataContext dataContext = new beDataContext(); be_User _be_User = new be_User(); _be_User.UserName = user.UserName; _be_User.Password = string.Empty; _be_User.LastLoginTime = DateTime.Now; _be_User.EmailAddress = user.Email; dataContext.be_Users.InsertOnSubmit(_be_User); dataContext.SubmitChanges(); } catch { } Roles.AddUserToRole(user.UserName, "Registered"); if (SiteSettings.Instance.CreateWikiUserAccount) { WikiUsers.AddUser(txtUsername.Text, txtEmailAddress.Text, null, txtDisplayName.Text); } SueetieUser sueetieUser = new SueetieUser(); sueetieUser.UserName = user.UserName.ToLower(); sueetieUser.Email = user.Email.ToLower(); sueetieUser.MembershipID = (Guid)user.ProviderUserKey; sueetieUser.DisplayName = txtDisplayName.Text; sueetieUser.IP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; sueetieUser.IsActive = true; sueetieUser.TimeZone = Convert.ToInt32(ddTimeZones.SelectedValue); int userid = SueetieUsers.CreateSueetieUser(sueetieUser); SueetieForums.CreateForumUser(sueetieUser); Uri uri = HttpContext.Current.Request.Url; string port = uri.Port != 80 ? ":" + uri.Port : string.Empty; if (registrationType == SueetieRegistrationType.EmailVerification) { string valBinary; valBinary = user.CreationDate.ToBinary().ToString(); MailMessage msg = new MailMessage(); msg.From = new MailAddress(SiteSettings.Instance.FromEmail, SiteSettings.Instance.FromName); MailAddress userAddress = new MailAddress(user.Email.ToLower().ToString(), txtDisplayName.Text.ToString()); msg.To.Add(userAddress); msg.Subject = string.Format(SueetieLocalizer.GetString("register_emailvalidation_subject"), SiteSettings.Instance.SiteName); string msgbody; string activateUrl = uri.Scheme + Uri.SchemeDelimiter + uri.Host + port + "/members/Activate.aspx"; msgbody = string.Format(SueetieLocalizer.GetString("register_emailvalidation_firstline"), SiteSettings.Instance.SiteName); msgbody += Environment.NewLine + Environment.NewLine; msgbody += activateUrl + "?uname=" + user.UserName + "&uid=" + userid + "&key=" + valBinary; msgbody += Environment.NewLine + Environment.NewLine; msgbody += SueetieLocalizer.GetString("register_emailvalidation_yourusername") + txtUsername.Text + Environment.NewLine; //msgbody += SueetieLocalizer.GetString("register_emailvalidation_yourpassword") + txtPassword1.Text + Environment.NewLine; msg.Body = msgbody; if (SueetieConfiguration.Get().Core.SendEmails) { EmailHelper.AsyncSendEmail(msg); } } else if (registrationType == SueetieRegistrationType.AdministrativeApproval) { string approveUrl = uri.Scheme + Uri.SchemeDelimiter + uri.Host + port + "/admin/approveusers.aspx"; MailMessage msg = new MailMessage(); msg.From = new MailAddress(SiteSettings.Instance.FromEmail, SiteSettings.Instance.FromName); MailAddress userAddress = new MailAddress(SiteSettings.Instance.ContactEmail, SiteSettings.Instance.SiteName + SueetieLocalizer.GetString("register_emailtoadmin_admin")); msg.To.Add(userAddress); msg.Subject = SueetieLocalizer.GetString("register_emailtoadmin_subject"); string msgbody; msgbody = SueetieLocalizer.GetString("register_emailtoadmin_firstline"); msgbody += Environment.NewLine + Environment.NewLine; msgbody += user.UserName.ToString() + " (" + sueetieUser.DisplayName + ")"; msgbody += Environment.NewLine + Environment.NewLine; msgbody += approveUrl; msg.Body = msgbody; if (SueetieConfiguration.Get().Core.SendEmails) { EmailHelper.AsyncSendEmail(msg); } } if (registrationType != SueetieRegistrationType.Automatic) { SaltieUserEvents.OnPreUserAccountApproval(CurrentSueetieUser); SueetieLogs.LogUserEntry(UserLogCategoryType.Registered, -1, userid); } switch (registrationType) { case SueetieRegistrationType.Automatic: SaltieUserEvents.OnPostUserAccountApproval(sueetieUser); SueetieUsers.CreateUpdateUserProfileCookie(sueetieUser); SueetieLogs.LogUserEntry(UserLogCategoryType.JoinedCommunity, -1, userid); string returnUrl = Request.QueryString["ReturnUrl"]; if (returnUrl != null) { Response.Redirect(returnUrl); } else { Response.Redirect("/members/welcome.aspx", true); } break; case SueetieRegistrationType.EmailVerification: Response.Redirect("/members/message.aspx?msgid=6"); break; case SueetieRegistrationType.AdministrativeApproval: Response.Redirect("/members/message.aspx?msgid=7"); break; default: break; } }