-
+
{{ formatMessage(messages.createAccountButton) }}
@@ -209,6 +209,15 @@ if (auth.value.user) {
const captcha = ref()
+const { data: globals } = await useAsyncData('auth-globals', async () => {
+ try {
+ return await useBaseFetch('globals', { internal: true })
+ } catch (err) {
+ console.error('Error fetching globals:', err)
+ return { captcha_enabled: true }
+ }
+})
+
const email = ref('')
const username = ref('')
const password = ref('')
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),
);
}