protected void registerButton_Click(object sender, EventArgs e) { if (databaseConnector.checkUserCredentials(emailTextBox.Text, passwordTextBox.Text)) { if (captcha.Visible) { var encodedResponse = Request.Form["g-Recaptcha-Response"]; VerifyReCaptcha captcha = new VerifyReCaptcha(); bool isCaptchaValid = captcha.verifyCapcha(encodedResponse); if (isCaptchaValid) { succesfulLogIn(); System.Diagnostics.Debug.WriteLine("You are a real person"); } else { System.Diagnostics.Debug.WriteLine("You are not human!"); robotLabel.Visible = true; wrongEmailOrPasswordLabel.Visible = false; } } else { succesfulLogIn(); } } else { System.Diagnostics.Debug.WriteLine("NOT logged in"); int newValue = (int)Session["failedLoginAttempts"] + 1; Session.Add("failedLoginAttempts", newValue); wrongEmailOrPasswordLabel.Visible = true; } }
protected void registerButton_Click(object sender, EventArgs e) { // if (checkIfTextFieldsEmpty()) //{ this.Validate(); // accountCreatedLabel.Visible = Page.IsValid; var encodedResponse = Request.Form["g-Recaptcha-Response"]; VerifyReCaptcha captcha = new VerifyReCaptcha(); bool isCaptchaValid = captcha.verifyCapcha(encodedResponse); if (isCaptchaValid) { System.Diagnostics.Debug.WriteLine("You are a real person!"); if (this.IsValid) //Needs to fulfill all validating { accountCreatedLabel.Visible = true; String activationCode = Membership.GeneratePassword(10, 0); activationCode = activationCode.Replace("&", "A").Replace("(", "A").Replace(")", "A").Replace(";", "A").Replace(":", "A").Replace("%", "A").Replace("[", "A").Replace("]", "A").Replace("{", "A").Replace("}", "A").Replace("-", "A").Replace("*", "A").Replace("#", "A").Replace("|", "A"); SendMail sendMail = new SendMail(); string msg = "Hello " + userNameTextBox.Text + "!"; msg += "<br/>In order to use your account you need to activate it first."; msg += "<br/><br/>Please click the link to activate your account: "; msg += "<br/><a href = '" + Request.Url.AbsoluteUri.Replace("Register_WebForm", "Activation_WebForm.aspx?confirmationCode=" + activationCode) + "'>Activate here!</a>"; databaseConnector.insertCustomer(nameTextBox.Text, streetAdressTextBox.Text, cityTextbox.Text, postCodetextBox.Text, emailTextBox.Text, passwordTextBox.Text, userNameTextBox.Text, 0, activationCode); System.Diagnostics.Debug.WriteLine("inserted User in database"); sendMail.mailer(emailTextBox.Text, "Account Activation", msg); } } else { System.Diagnostics.Debug.WriteLine("You are not human!"); robotLabel.Visible = true; } //} // else // { // System.Diagnostics.Debug.WriteLine("have empty reg fields"); // } }