mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 11:36:05 +00:00
chore: omit ip from usercheck decision requests
This commit is contained in:
@@ -24,7 +24,6 @@ use crate::util::error::ApiContext as _;
|
||||
use crate::util::error::Context;
|
||||
use crate::util::ext::get_image_ext;
|
||||
use crate::util::img::upload_image_optimized;
|
||||
use crate::util::ip::client_ip;
|
||||
use crate::util::neverbounce::{check_email, email_check_error_generic};
|
||||
use crate::util::usercheck::{
|
||||
DecisionAction, check_email_gate, gate_block_error,
|
||||
@@ -1545,7 +1544,7 @@ pub async fn create_oauth_account(
|
||||
};
|
||||
|
||||
if let Some(email) = &user.email {
|
||||
ensure_email_passes_gate(&req, email)
|
||||
ensure_email_passes_gate(email)
|
||||
.await
|
||||
.wrap_api_err("validating email passes the signup gate")?;
|
||||
}
|
||||
@@ -1903,11 +1902,8 @@ impl From<NewAccount> for AccountRegisterFlow {
|
||||
}
|
||||
|
||||
/// Runs the UserCheck gate, which covers both password and OAuth signups.
|
||||
async fn ensure_email_passes_gate(
|
||||
req: &HttpRequest,
|
||||
email: &str,
|
||||
) -> Result<(), ApiError> {
|
||||
let action = check_email_gate(email, client_ip(req).as_deref())
|
||||
async fn ensure_email_passes_gate(email: &str) -> Result<(), ApiError> {
|
||||
let action = check_email_gate(email)
|
||||
.await
|
||||
.wrap_request_err("checking email address")?;
|
||||
|
||||
@@ -1918,11 +1914,8 @@ async fn ensure_email_passes_gate(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn ensure_email_is_usable(
|
||||
req: &HttpRequest,
|
||||
email: &str,
|
||||
) -> Result<(), ApiError> {
|
||||
ensure_email_passes_gate(req, email).await?;
|
||||
async fn ensure_email_is_usable(email: &str) -> Result<(), ApiError> {
|
||||
ensure_email_passes_gate(email).await?;
|
||||
|
||||
let result = check_email(email)
|
||||
.await
|
||||
@@ -2151,7 +2144,7 @@ pub async fn create_account_with_password(
|
||||
)));
|
||||
}
|
||||
|
||||
ensure_email_is_usable(&req, &new_account.email)
|
||||
ensure_email_is_usable(&new_account.email)
|
||||
.await
|
||||
.wrap_api_err("validating email is usable")?;
|
||||
|
||||
@@ -3136,7 +3129,7 @@ pub async fn set_email(
|
||||
)));
|
||||
}
|
||||
|
||||
ensure_email_is_usable(&req, &email_address.email)
|
||||
ensure_email_is_usable(&email_address.email)
|
||||
.await
|
||||
.wrap_api_err("validating email is usable")?;
|
||||
|
||||
|
||||
@@ -76,8 +76,6 @@ struct ResponseMeta {
|
||||
#[derive(Serialize)]
|
||||
struct DecisionRequest<'a> {
|
||||
email: &'a str,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
ip: Option<&'a str>,
|
||||
}
|
||||
|
||||
/// Asks the configured UserCheck gate whether a signup should proceed.
|
||||
@@ -87,10 +85,7 @@ struct DecisionRequest<'a> {
|
||||
/// signup, while anything else is an error that rejects the signup.
|
||||
/// `Challenge` resolves to `Allow` because these flows have no step-up
|
||||
/// mechanism past the captcha that already ran.
|
||||
pub async fn check_email_gate(
|
||||
email: &str,
|
||||
ip: Option<&str>,
|
||||
) -> eyre::Result<DecisionAction> {
|
||||
pub async fn check_email_gate(email: &str) -> eyre::Result<DecisionAction> {
|
||||
if ENV.USERCHECK_API_KEY.is_empty() || ENV.USERCHECK_GATE_ID.is_empty() {
|
||||
debug!(
|
||||
action = "allow",
|
||||
@@ -100,7 +95,7 @@ pub async fn check_email_gate(
|
||||
}
|
||||
|
||||
let decision_time_start = Instant::now();
|
||||
let response = request_decision(email, ip).await;
|
||||
let response = request_decision(email).await;
|
||||
let decision_time = decision_time_start.elapsed();
|
||||
|
||||
let response = match response {
|
||||
@@ -180,10 +175,7 @@ pub fn gate_block_error() -> eyre::Error {
|
||||
)
|
||||
}
|
||||
|
||||
async fn request_decision(
|
||||
email: &str,
|
||||
ip: Option<&str>,
|
||||
) -> reqwest::Result<DecisionResponse> {
|
||||
async fn request_decision(email: &str) -> reqwest::Result<DecisionResponse> {
|
||||
HTTP_CLIENT
|
||||
.post(format!(
|
||||
"{}/v0/gates/{}/decisions",
|
||||
@@ -192,7 +184,7 @@ async fn request_decision(
|
||||
))
|
||||
.bearer_auth(&ENV.USERCHECK_API_KEY)
|
||||
.timeout(TIMEOUT)
|
||||
.json(&DecisionRequest { email, ip })
|
||||
.json(&DecisionRequest { email })
|
||||
.send()
|
||||
.await?
|
||||
.error_for_status()?
|
||||
|
||||
Reference in New Issue
Block a user