mirror of
https://github.com/modrinth/code.git
synced 2026-08-27 18:14:49 +00:00
@@ -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?
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user