bool CheckRecaptcha(string email, Info info, out double score) { score = 0; Recaptcha.Token token; // Val ReCaptchaV3: Since 1st login Posts to this page your can't use ReCaptcha if (!Recaptcha.IsValidV3(Request.Form["g-recaptcha-responsev3"], true, out token)) { return(false); // Can't throw error (above) } score = token.Score; // SQL Save Human Score if (_sql.State == ConnectionState.Closed) { _sql.Open(); } // SQL Make sure there is a day change to submit ---------------------- var com = new SqlCommand("SELECT TOP 1 [dateTime] FROM [HumanScore] WHERE [userid]=@userid ORDER BY [dateTime] DESC", _sql); com.Parameters.AddWithValue("@userid", info.id); var reader = com.ExecuteReader(); bool add; // Make sure it is a different day if (reader.Read()) { add = Data.DateTimeValue(DateTime.Now) != (int)reader["dateTime"]; } else { add = true; } reader.Close(); // SQL: Insert HumanScore if true -------------------------------------- if (add) { com = new SqlCommand("INSERT INTO [HumanScore] ([userid],[humanScore],[dateTime],[page]) VALUES (@userid,@humanScore,@dateTime,@page)", _sql); com.Parameters.AddWithValue("@userid", info.id); com.Parameters.AddWithValue("@humanScore", (float)token.Score); com.Parameters.AddWithValue("@dateTime", Data.DateTimeValue(DateTime.Now)); com.Parameters.AddWithValue("@page", "Login"); if (com.ExecuteNonQuery() == 0) { throw new Exception("Could Not insert HumanScore. email: " + info.Email); } } // SQL: Delete Older data of 50+ --------------------------------------- com = new SqlCommand("DELETE FROM [HumanScore] WHERE [id] IN " + "(SELECT [id] FROM (SELECT [id],ROW_NUMBER() OVER(ORDER BY [dateTime] DESC) AS rw FROM [HumanScore] WHERE [userid]=@userid)" + "res WHERE res.rw > @max)", _sql); com.Parameters.AddWithValue("@userid", info.id); com.Parameters.AddWithValue("@max", 5); com.ExecuteNonQuery(); // Ok, if No rows updated // Return return(true); }
bool CheckRecaptcha(string email) { Recaptcha.Token token; // Val ReCaptchaV2 Checkbox if (!Recaptcha.IsValidV3(Request.Form["g-recaptcha-response"], false, out token)) { lbErrorMsg.Text = "Please check the ReCaptcha checkbox at the bottom and follow the prompt if need be. Additionally, check the checkbox before clicking the submit button."; return(false); } // Return true return(true); }
// Re-Captcha bool CheckRecaptcha(string email, out double score) { Recaptcha.Token token; score = 0; // Val ReCaptchaV3 if (!Recaptcha.IsValidV3(Request.Form["g-recaptcha-responsev3"], true, out token)) { throw new Exception("ReCaptchaV3 was unsuccessful. email: " + email); } score = token.Score; return(token.Success); }
bool CheckRecaptcha(string email, out double score) { Recaptcha.Token token; score = 0; // Val ReCaptchaV2 Checkbox if (!Recaptcha.IsValidV3(Request.Form["g-recaptcha-response"], false, out token)) { lbErrorMsg.Text = "Please check the ReCaptcha checkbox at the bottom and follow the prompt if need be. Additionally, check the checkbox before clicking the submit button."; return(false); } // Val ReCaptchaV3 if (!Recaptcha.IsValidV3(Request.Form["g-recaptcha-responsev3"], true, out token)) { throw new Exception("ReCaptchaV3 was unsuccessful. email: " + email); } score = token.Score; return(token.Success); }
bool CheckRecaptcha(string email, Info info, out double score) { score = 0; Recaptcha.Token token; // Val ReCaptchaV2-- Checkbox if (!Recaptcha.IsValidV3(Request.Form["g-recaptcha-response"], false, out token)) { lbErrorMsg.Text = "Please check the ReCaptcha checkbox at the bottom and follow the prompt if need be. Additionally, check the checkbox before clicking the submit button."; return(false); } // Val ReCaptchaV3-- Ok to throw Error if (!Recaptcha.IsValidV3(Request.Form["g-recaptcha-responsev3"], true, out token)) { throw new Exception("ReCaptchaV3 was unsuccessful. email: " + email); } score = token.Score; // SQL Save Human Score if (_sql.State == ConnectionState.Closed) { _sql.Open(); } // SQL Make sure there is a day change to submit ---------------------- var com = new SqlCommand("SELECT TOP 1 [dateTime] FROM [HumanScore] WHERE [userid]=@userid ORDER BY [dateTime] DESC", _sql); com.Parameters.AddWithValue("@userid", info.id); var reader = com.ExecuteReader(); bool add; // Make sure it is a different day if (reader.Read()) { add = Data.DateTimeValue(DateTime.Now) != (int)reader["dateTime"]; } else { add = true; } reader.Close(); // SQL: Insert HumanScore if true -------------------------------------- if (add) { com = new SqlCommand("INSERT INTO [HumanScore] ([userid],[humanScore],[dateTime],[page]) VALUES (@userid,@humanScore,@dateTime,@page)", _sql); com.Parameters.AddWithValue("@userid", info.id); com.Parameters.AddWithValue("@humanScore", (float)token.Score); com.Parameters.AddWithValue("@dateTime", Data.DateTimeValue(DateTime.Now)); com.Parameters.AddWithValue("@page", "PasswordReset"); if (com.ExecuteNonQuery() == 0) { throw new Exception("Could Not insert HumanScore. email: " + info.Email); } } // SQL: Delete Older data of 50+ --------------------------------------- com = new SqlCommand("DELETE FROM [HumanScore] WHERE [id] IN " + "(SELECT [id] FROM (SELECT [id],ROW_NUMBER() OVER(ORDER BY [dateTime] DESC) AS rw FROM [HumanScore] WHERE [userid]=@userid)" + "res WHERE res.rw > @max)", _sql); com.Parameters.AddWithValue("@userid", info.id); com.Parameters.AddWithValue("@max", 5); com.ExecuteNonQuery(); // Ok, if No rows updated // Return return(true); }