From 5d84f17600e179280e44c391b92ee9eecc2b7cdc Mon Sep 17 00:00:00 2001 From: Stefan Melmuk <509385+stefan0xC@users.noreply.github.com> Date: Tue, 29 Jul 2025 12:13:02 +0200 Subject: [PATCH] fix hiding of signup link (#6113) The registration link should be hidden if signup is not allowed and whitelist is empty unless mail is disabled and invitations are allowed --- src/api/core/mod.rs | 2 +- src/api/web.rs | 2 +- src/config.rs | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index c30b4e8d..ca1c1561 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -225,7 +225,7 @@ fn config() -> Json { "url": "https://github.com/dani-garcia/vaultwarden" }, "settings": { - "disableUserRegistration": !crate::CONFIG.signups_allowed() && crate::CONFIG.signups_domains_whitelist().is_empty(), + "disableUserRegistration": crate::CONFIG.is_signup_disabled() }, "environment": { "vault": domain, diff --git a/src/api/web.rs b/src/api/web.rs index c4faf58c..f3516b47 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -55,7 +55,7 @@ fn not_found() -> ApiResult> { #[get("/css/vaultwarden.css")] fn vaultwarden_css() -> Cached> { let css_options = json!({ - "signup_disabled": !CONFIG.signups_allowed() && CONFIG.signups_domains_whitelist().is_empty(), + "signup_disabled": CONFIG.is_signup_disabled(), "mail_enabled": CONFIG.mail_enabled(), "mail_2fa_enabled": CONFIG._enable_email_2fa(), "yubico_enabled": CONFIG._enable_yubico() && CONFIG.yubico_client_id().is_some() && CONFIG.yubico_secret_key().is_some(), diff --git a/src/config.rs b/src/config.rs index 5a3d060f..86e11517 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1354,6 +1354,14 @@ impl Config { } } + // The registration link should be hidden if signup is not allowed and whitelist is empty + // unless mail is disabled and invitations are allowed + pub fn is_signup_disabled(&self) -> bool { + !self.signups_allowed() + && self.signups_domains_whitelist().is_empty() + && (self.mail_enabled() || !self.invitations_allowed()) + } + /// Tests whether the specified user is allowed to create an organization. pub fn is_org_creation_allowed(&self, email: &str) -> bool { let users = self.org_creation_users();