private async Task OnClick()
 {
     if (!string.IsNullOrEmpty(Ip))
     {
         Location = await IPLocator.Locate(Ip);
     }
 }
Example #2
0
        public bool AutorizeAndCheckSpam()
        {
            string    login1     = ConfigurationManager.AppSettings["login1"];
            string    pass1      = ConfigurationManager.AppSettings["password1"];
            string    login2     = ConfigurationManager.AppSettings["login2"];
            string    pass2      = ConfigurationManager.AppSettings["password2"];
            string    ip         = ConfigurationManager.AppSettings["ip"];
            IPLocator ipl        = new IPLocator(ip);
            string    textToSend = $"Hello, Dear. \r\n I'm writing you from {ipl.GetCityByIP()}. Weather is perfect. I'm waiting for You.";
            LoginPage loginPage  = new LoginPage();

            loginPage.OpenPage();
            loginPage.SetLoginAndPassword(login1, pass1);
            EmailPage emailPage = new EmailPage();

            emailPage.SendEmail(login2, textToSend);
            emailPage.Logout();
            loginPage.SwitchUser();
            loginPage.SetLoginAndPassword(login2, pass2);
            emailPage.AddToSpam();
            emailPage.Logout();
            loginPage.SwitchUser();
            loginPage.SetLoginAndPassword(login1, pass1);
            emailPage.SendEmail(login2, $"new {textToSend}");
            emailPage.Logout();
            loginPage.SwitchUser();
            loginPage.SetLoginAndPassword(login2, pass2);
            emailPage.GoToSpam();
            return(emailPage.CheckSpam($"new {textToSend}"));
        }
Example #3
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.CreateUserWizard1.MembershipProvider = Config.MembershipProvider;

                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink(this.GetText("TITLE"));

                // handle the CreateUser Step localization
                this.SetupCreateUserStep();

                // handle other steps localization
                ((Button)this.CreateUserWizard1.FindWizardControlRecursive("ProfileNextButton")).Text = this.GetText("SAVE");
                ((Button)this.CreateUserWizard1.FindWizardControlRecursive("ContinueButton")).Text    = this.GetText("CONTINUE");

                // get the time zone data source
                var timeZones = (DropDownList)this.CreateUserWizard1.FindWizardControlRecursive("TimeZones");
                timeZones.DataSource = StaticDataHelper.TimeZones();

                if (_userIpLocator == null)
                {
                    // vzrus: we should always get not null class here
                    _userIpLocator = new IPDetails().GetData(HttpContext.Current.Request.UserHostAddress, true);
                }
                // fill dst field
                if (this._userIpLocator.Isdst.IsSet() && _userIpLocator.Status.ToUpper() == "OK")
                {
                    this.CreateUserWizard1.FindControlRecursiveAs <CheckBox>("DSTUser").Checked = _userIpLocator.Isdst == "1" ? true : false;
                }
                // fill location field
                if (this._userIpLocator.Isdst.IsSet() && _userIpLocator.Status.ToUpper() == "OK")
                {
                    // Trying to consume data about user IP whereabouts
                    if (_userIpLocator.Status == "OK")
                    {
                        string txtLoc = String.Empty;
                        if (this._userIpLocator.CountryName.IsSet())
                        {
                            txtLoc += _userIpLocator.CountryName;
                        }
                        if (this._userIpLocator.RegionName.IsSet())
                        {
                            txtLoc += ", " + _userIpLocator.RegionName;
                        }
                        if (this._userIpLocator.City.IsSet())
                        {
                            txtLoc += ", " + _userIpLocator.City;
                        }
                        this.CreateUserWizard1.FindControlRecursiveAs <TextBox>("Location").Text = txtLoc;
                    }
                }


                if (!this.PageContext.BoardSettings.EmailVerification)
                {
                    // automatically log in created users
                    this.CreateUserWizard1.LoginCreatedUser   = true;
                    this.CreateUserWizard1.DisableCreatedUser = false;

                    // success notification localization
                    ((Literal)this.CreateUserWizard1.FindWizardControlRecursive("AccountCreated")).Text =
                        YafBBCode.MakeHtml(this.GetText("ACCOUNT_CREATED"), true, false);
                }
                else
                {
                    this.CreateUserWizard1.LoginCreatedUser   = false;
                    this.CreateUserWizard1.DisableCreatedUser = true;

                    // success notification localization
                    ((Literal)this.CreateUserWizard1.FindWizardControlRecursive("AccountCreated")).Text =
                        YafBBCode.MakeHtml(this.GetText("ACCOUNT_CREATED_VERIFICATION"), true, false);
                }

                this.CreateUserWizard1.FinishDestinationPageUrl = YafForumInfo.ForumURL;

                this.DataBind();
                int tz = 0;
                if (_userIpLocator.Status == "OK")
                {
                    if (this._userIpLocator.Gmtoffset.IsSet() && (this._userIpLocator.Isdst.IsSet()))
                    {
                        tz = (Convert.ToInt32(_userIpLocator.Gmtoffset) - Convert.ToInt32(_userIpLocator.Isdst) * 3600) / 60;
                    }
                }

                timeZones.Items.FindByValue(tz.ToString()).Selected = true;
                this.CreateUserWizard1.FindWizardControlRecursive("UserName").Focus();
            }

            // password requirement parameters...
            var requirementText = (LocalizedLabel)this.CreateUserStepContainer.FindControl("LocalizedLabelRequirementsText");

            requirementText.Param0 = this.PageContext.CurrentMembership.MinRequiredPasswordLength.ToString();
            requirementText.Param1 = this.PageContext.CurrentMembership.MinRequiredNonAlphanumericCharacters.ToString();

            // max user name length
            var usernamelehgthText =
                (LocalizedLabel)this.CreateUserStepContainer.FindControl("LocalizedLabelLohgUserNameWarnText");

            usernamelehgthText.Param0 = this.PageContext.BoardSettings.UserNameMaxLength.ToString();

            if (this.PageContext.BoardSettings.CaptchaTypeRegister == 2)
            {
                this.SetupRecaptchaControl();
            }
        }