Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Allow invite only and Discourse connect (#20961)

Bianca Nenciu9ff105973fce
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 5cfd329a445..42a8b91a281 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -2438,7 +2438,6 @@ en:
staged_users_disabled: "You must first enable 'staged users' before enabling this setting."
reply_by_email_disabled: "You must first enable 'reply by email' before enabling this setting."
discourse_connect_url_is_empty: "You must set a 'discourse connect url' before enabling this setting."
- discourse_connect_invite_only: "You cannot enable DiscourseConnect and invite only at the same time."
enable_local_logins_disabled: "You must first enable 'enable local logins' before enabling this setting."
min_username_length_exists: "You cannot set the minimum username length above the shortest username (%{username})."
min_username_length_range: "You cannot set the minimum above the maximum."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 4f36dc7fb4e..68449069bb7 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -391,7 +391,6 @@ login:
refresh: true
client: true
default: false
- validator: "EnableInviteOnlyValidator"
login_required:
refresh: true
client: true
diff --git a/lib/validators/enable_invite_only_validator.rb b/lib/validators/enable_invite_only_validator.rb
deleted file mode 100644
index 89e062ff162..00000000000
--- a/lib/validators/enable_invite_only_validator.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# frozen_string_literal: true
-
-class EnableInviteOnlyValidator
- def initialize(opts = {})
- @opts = opts
- end
-
- def valid_value?(val)
- return true if val == "f"
- !SiteSetting.enable_discourse_connect?
- end
-
- def error_message
- I18n.t("site_settings.errors.discourse_connect_invite_only")
- end
-end
diff --git a/lib/validators/enable_sso_validator.rb b/lib/validators/enable_sso_validator.rb
index 3d75391f53b..84281afd799 100644
--- a/lib/validators/enable_sso_validator.rb
+++ b/lib/validators/enable_sso_validator.rb
@@ -7,9 +7,7 @@ class EnableSsoValidator
def valid_value?(val)
return true if val == "f"
- if SiteSetting.discourse_connect_url.blank? || SiteSetting.invite_only? || is_2fa_enforced?
- return false
- end
+ return false if SiteSetting.discourse_connect_url.blank? || is_2fa_enforced?
true
end
@@ -17,7 +15,7 @@ class EnableSsoValidator
if SiteSetting.discourse_connect_url.blank?
return I18n.t("site_settings.errors.discourse_connect_url_is_empty")
end
- return I18n.t("site_settings.errors.discourse_connect_invite_only") if SiteSetting.invite_only?
+
if is_2fa_enforced?
I18n.t("site_settings.errors.discourse_connect_cannot_be_enabled_if_second_factor_enforced")
end
diff --git a/spec/lib/validators/enable_sso_validator_spec.rb b/spec/lib/validators/enable_sso_validator_spec.rb
index 1237a0028b8..edbdb21c474 100644
--- a/spec/lib/validators/enable_sso_validator_spec.rb
+++ b/spec/lib/validators/enable_sso_validator_spec.rb
@@ -24,24 +24,6 @@ RSpec.describe EnableSsoValidator do
end
end
- describe "when invite_only is set" do
- before do
- SiteSetting.invite_only = true
- SiteSetting.discourse_connect_url = "https://example.com/sso"
- end
-
- it "allows a false value" do
- expect(subject.valid_value?("f")).to eq(true)
- end
-
- it "doesn't allow true" do
- expect(subject.valid_value?("t")).to eq(false)
- expect(subject.error_message).to eq(
- I18n.t("site_settings.errors.discourse_connect_invite_only"),
- )
- end
- end
-
describe "when 'sso url' is present" do
before { SiteSetting.discourse_connect_url = "https://www.example.com/sso" }