feat: honeypot signup field (#6776)

feat: account consent
This commit is contained in:
François-Xavier Talbot
2026-07-19 21:54:23 +00:00
committed by GitHub
parent 6b569e4ee4
commit c579925f03
5 changed files with 41 additions and 5 deletions
@@ -1438,6 +1438,19 @@ struct NewOAuthAccount {
pub state: String,
pub challenge: String,
pub sign_up_newsletter: bool,
#[serde(default)]
pub account_consent: bool,
}
fn validate_account_consent(account_consent: bool) -> Result<(), ApiError> {
if account_consent {
info!("account consent trigger, denying");
return Err(ApiError::Request(eyre!(
"Sorry, something went wrong. Please try again"
)));
}
Ok(())
}
/// Create account with OAuth.
@@ -1463,6 +1476,8 @@ pub async fn create_oauth_account(
ApiError::InvalidInput(validation_errors_to_string(err, None))
})?;
validate_account_consent(new_account.account_consent)?;
if !check_hcaptcha(&req, &new_account.challenge).await? {
return Err(ApiError::Turnstile);
}
@@ -1709,6 +1724,8 @@ pub struct NewAccount {
pub email: String,
pub challenge: Option<String>,
pub sign_up_newsletter: Option<bool>,
#[serde(default)]
pub account_consent: bool,
}
#[derive(Debug, Validate)]
@@ -1996,6 +2013,8 @@ pub async fn create_account_with_password(
) -> Result<HttpResponse, ApiError> {
let new_account = new_account.into_inner();
validate_account_consent(new_account.account_consent)?;
if !check_hcaptcha(&req, new_account.challenge.as_deref().unwrap_or(""))
.await?
{