Skip to content

Commit 5d84f17

Browse files
authored
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
1 parent 0db4b00 commit 5d84f17

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/api/core/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn config() -> Json<Value> {
225225
"url": "https://github.com/dani-garcia/vaultwarden"
226226
},
227227
"settings": {
228-
"disableUserRegistration": !crate::CONFIG.signups_allowed() && crate::CONFIG.signups_domains_whitelist().is_empty(),
228+
"disableUserRegistration": crate::CONFIG.is_signup_disabled()
229229
},
230230
"environment": {
231231
"vault": domain,

src/api/web.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn not_found() -> ApiResult<Html<String>> {
5555
#[get("/css/vaultwarden.css")]
5656
fn vaultwarden_css() -> Cached<Css<String>> {
5757
let css_options = json!({
58-
"signup_disabled": !CONFIG.signups_allowed() && CONFIG.signups_domains_whitelist().is_empty(),
58+
"signup_disabled": CONFIG.is_signup_disabled(),
5959
"mail_enabled": CONFIG.mail_enabled(),
6060
"mail_2fa_enabled": CONFIG._enable_email_2fa(),
6161
"yubico_enabled": CONFIG._enable_yubico() && CONFIG.yubico_client_id().is_some() && CONFIG.yubico_secret_key().is_some(),

src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,14 @@ impl Config {
13541354
}
13551355
}
13561356

1357+
// The registration link should be hidden if signup is not allowed and whitelist is empty
1358+
// unless mail is disabled and invitations are allowed
1359+
pub fn is_signup_disabled(&self) -> bool {
1360+
!self.signups_allowed()
1361+
&& self.signups_domains_whitelist().is_empty()
1362+
&& (self.mail_enabled() || !self.invitations_allowed())
1363+
}
1364+
13571365
/// Tests whether the specified user is allowed to create an organization.
13581366
pub fn is_org_creation_allowed(&self, email: &str) -> bool {
13591367
let users = self.org_creation_users();

0 commit comments

Comments
 (0)