Exemplo n.º 1
0
        /// <summary>
        /// Handles the CreatingUser event of the RegisterUser control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.LoginCancelEventArgs"/> instance containing the event data.</param>
        protected void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e)
        {
            App_Code.Controls.RecaptchaControl captcha =
                (App_Code.Controls.RecaptchaControl)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("recaptcha") as App_Code.Controls.RecaptchaControl;

            if (Membership.GetUser(this.RegisterUser.UserName) != null)
            {
                e.Cancel = true;
                this.Master.SetStatus("warning", Resources.labels.anotherUserName);
            }
            else if (Membership.GetUserNameByEmail(this.RegisterUser.Email) != null)
            {
                e.Cancel = true;
                this.Master.SetStatus("warning", Resources.labels.anotherEmail);
            }
            else if (captcha != null)
            {
                captcha.Validate();

                if (!captcha.IsValid)
                {
                    e.Cancel = true;
                    this.Master.SetStatus("warning", "Captcha invalid.");
                }
            }
        }
Exemplo n.º 2
0
 public void SetCaptcha(ControlCollection controls)
 {
     foreach (Control ctl in controls)
     {
         if (ctl is WebControl)
         {
             if (ctl.ToString().Contains("RecaptchaControl"))
             {
                 captcha = (App_Code.Controls.RecaptchaControl)ctl;
                 return;
             }
         }
         if (ctl.Controls.Count > 0) SetCaptcha(ctl.Controls);
     }
 }
Exemplo n.º 3
0
 public void SetCaptcha(ControlCollection controls)
 {
     foreach (Control ctl in controls)
     {
         if (ctl is WebControl)
         {
             if (ctl.ToString().Contains("RecaptchaControl"))
             {
                 captcha = (App_Code.Controls.RecaptchaControl)ctl;
                 return;
             }
         }
         if (ctl.Controls.Count > 0)
         {
             SetCaptcha(ctl.Controls);
         }
     }
 }