From dc9a11d59b09091238f0eeb4834a1889158eee1d Mon Sep 17 00:00:00 2001 From: aecsocket Date: Tue, 3 Feb 2026 16:50:55 +0000 Subject: [PATCH 1/6] Add /_internal/globals route --- apps/labrinth/src/routes/internal/globals.rs | 39 ++++++++++++++++++++ apps/labrinth/src/routes/internal/mod.rs | 6 +++ 2 files changed, 45 insertions(+) create mode 100644 apps/labrinth/src/routes/internal/globals.rs diff --git a/apps/labrinth/src/routes/internal/globals.rs b/apps/labrinth/src/routes/internal/globals.rs new file mode 100644 index 0000000000..092af9ecc2 --- /dev/null +++ b/apps/labrinth/src/routes/internal/globals.rs @@ -0,0 +1,39 @@ +use std::{collections::HashMap, sync::LazyLock}; + +use actix_web::{get, web}; +use serde::{Deserialize, Serialize}; + +pub fn config(cfg: &mut utoipa_actix_web::service_config::ServiceConfig) { + cfg.service(get_globals); +} + +/// See [`get`]. +#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] +pub struct Globals { + /// Map of years to how much a creator can withdraw in that year, in USD, + /// before they must fill in a tax compliance form. + /// + /// If the current year is not contained in this map: + /// - if the year is before the first year in the map, the threshold is the first year's. + /// - if the year is after the last year in the map, the threshold is the last year's threshold. + pub tax_compliance_thresholds: HashMap, + /// If this backend instance has a Captcha enabled for password login. + /// + /// In production, this will always be true. On local testing builds, this + /// will always be false. + pub captcha_enabled: bool, +} + +static GLOBALS: LazyLock = LazyLock::new(|| Globals { + tax_compliance_thresholds: [(2025, 600), (2026, 2000)] + .into_iter() + .collect(), + captcha_enabled: dotenvy::var("HCAPTCHA_SECRET").is_ok_and(|x| x != "none"), +}); + +/// Gets configured global non-secret variables for this backend instance. +#[utoipa::path] +#[get("")] +pub async fn get_globals() -> web::Json { + web::Json(GLOBALS.clone()) +} diff --git a/apps/labrinth/src/routes/internal/mod.rs b/apps/labrinth/src/routes/internal/mod.rs index 13db90924a..e213bbf611 100644 --- a/apps/labrinth/src/routes/internal/mod.rs +++ b/apps/labrinth/src/routes/internal/mod.rs @@ -5,6 +5,7 @@ pub mod delphi; pub mod external_notifications; pub mod flows; pub mod gdpr; +pub mod globals; pub mod gotenberg; pub mod medal; pub mod moderation; @@ -55,5 +56,10 @@ pub fn utoipa_config( utoipa_actix_web::scope("/_internal/search-management") .wrap(default_cors()) .configure(search::config), + ) + .service( + utoipa_actix_web::scope("/_internal/globals") + .wrap(default_cors()) + .configure(globals::config), ); } From b3d21bb5b7eeaddeeb8ba8d3399f9cc50d11fcc9 Mon Sep 17 00:00:00 2001 From: aecsocket Date: Tue, 3 Feb 2026 16:58:35 +0000 Subject: [PATCH 2/6] Don't show login captcha if backend claims it's disabled --- apps/frontend/src/pages/auth/reset-password.vue | 12 ++++++++++-- apps/frontend/src/pages/auth/sign-in.vue | 8 ++++++-- apps/frontend/src/pages/auth/sign-up.vue | 8 ++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/apps/frontend/src/pages/auth/reset-password.vue b/apps/frontend/src/pages/auth/reset-password.vue index 2318d88d55..df89fe579e 100644 --- a/apps/frontend/src/pages/auth/reset-password.vue +++ b/apps/frontend/src/pages/auth/reset-password.vue @@ -22,9 +22,13 @@ /> - + - @@ -158,6 +162,10 @@ if (route.query.flow) { const captcha = ref() +const { data: globals } = await useAsyncData('auth-globals', () => + useBaseFetch('globals', { internal: true }), +) + const email = ref('') const token = ref('') diff --git a/apps/frontend/src/pages/auth/sign-in.vue b/apps/frontend/src/pages/auth/sign-in.vue index 6bdc2002db..454aeca3d3 100644 --- a/apps/frontend/src/pages/auth/sign-in.vue +++ b/apps/frontend/src/pages/auth/sign-in.vue @@ -89,11 +89,11 @@ /> - +