Consistently use ForemInstance.private? (#14021)
This commit is contained in:
parent
7ba3c3a81c
commit
7fe5c54161
12 changed files with 17 additions and 21 deletions
|
|
@ -95,10 +95,6 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
def invite_only_mode?
|
||||
Settings::Authentication.invite_only_mode?
|
||||
end
|
||||
|
||||
def any_enabled_auth_providers?
|
||||
authentication_enabled_providers.any?
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,22 +45,22 @@ module AuthenticationHelper
|
|||
Settings::General.waiting_on_first_user
|
||||
end
|
||||
|
||||
def invite_only_mode_or_no_enabled_auth_options
|
||||
Settings::Authentication.invite_only_mode ||
|
||||
def private_forem_or_no_enabled_auth_options
|
||||
ForemInstance.private? ||
|
||||
(authentication_enabled_providers.none? &&
|
||||
!Settings::Authentication.allow_email_password_registration)
|
||||
end
|
||||
|
||||
def tooltip_class_on_auth_provider_enablebtn
|
||||
invite_only_mode_or_no_enabled_auth_options ? "crayons-tooltip" : ""
|
||||
private_forem_or_no_enabled_auth_options ? "crayons-tooltip" : ""
|
||||
end
|
||||
|
||||
def disabled_attr_on_auth_provider_enable_btn
|
||||
invite_only_mode_or_no_enabled_auth_options ? "disabled" : ""
|
||||
private_forem_or_no_enabled_auth_options ? "disabled" : ""
|
||||
end
|
||||
|
||||
def tooltip_text_email_or_auth_provider_btns
|
||||
if invite_only_mode_or_no_enabled_auth_options
|
||||
if private_forem_or_no_enabled_auth_options
|
||||
"You cannot do this until you disable Invite Only Mode"
|
||||
else
|
||||
""
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ module Authentication
|
|||
# TODO: [@forem/oss] ideally this should be "available - disabled"
|
||||
# we can get there once we have feature flags
|
||||
def self.enabled
|
||||
return [] if Settings::Authentication.invite_only_mode
|
||||
return [] if ForemInstance.private?
|
||||
|
||||
Settings::Authentication.providers.map(&:to_sym).sort
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
General settings
|
||||
</h3>
|
||||
<div
|
||||
class="crayons-field crayons-field--checkbox <%= invite_only_mode_or_no_enabled_auth_options ? "crayons-tooltip" : "" %>"
|
||||
class="crayons-field crayons-field--checkbox <%= private_forem_or_no_enabled_auth_options ? "crayons-tooltip" : "" %>"
|
||||
data-tooltip="Unchecking this will enable Email Registration">
|
||||
<%= f.check_box :invite_only_mode,
|
||||
checked: invite_only_mode_or_no_enabled_auth_options,
|
||||
checked: private_forem_or_no_enabled_auth_options,
|
||||
data: { action: "config#adjustAuthenticationOptions", "config-target": "inviteOnlyMode" },
|
||||
class: "crayons-checkbox" %>
|
||||
<div class="mt-0">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="registration crayons-card">
|
||||
<div class="registration__content">
|
||||
<h1 class="registration__title">
|
||||
<% if params[:state] == "new-user" && invite_only_mode? %>
|
||||
<% if params[:state] == "new-user" && ForemInstance.private? %>
|
||||
<%= community_name %> is invite only.
|
||||
<% else %>
|
||||
Welcome to <%= community_name %>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if params[:state] == "new-user" && Settings::Authentication.allow_email_password_registration && !Settings::Authentication.invite_only_mode %>
|
||||
<% if params[:state] == "new-user" && Settings::Authentication.allow_email_password_registration && !ForemInstance.private? %>
|
||||
<%= link_to "#{inline_svg_tag('email.svg', aria_hidden: true, class: 'crayons-icon', title: 'email')}Sign up with Email".html_safe,
|
||||
request.params.merge(state: "email_signup").except("i"),
|
||||
class: "crayons-btn crayons-btn--l crayons-btn--brand-email crayons-btn--icon-left whitespace-nowrap",
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ RSpec.describe AuthenticationHelper, type: :helper do
|
|||
|
||||
describe "#authentication_provider_enabled?" do
|
||||
before do
|
||||
allow(Settings::Authentication).to receive(:invite_only_mode).and_return(false)
|
||||
allow(ForemInstance).to receive(:private?).and_return(false)
|
||||
allow(Settings::Authentication).to receive(:providers).and_return(%i[twitter github])
|
||||
end
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ RSpec.describe AuthenticationHelper, type: :helper do
|
|||
describe "tooltip classes, attributes and content" do
|
||||
context "when invite-only-mode enabled and no enabled registration options" do
|
||||
before do
|
||||
allow(Settings::Authentication).to receive(:invite_only_mode).and_return(true)
|
||||
allow(ForemInstance).to receive(:private?).and_return(true)
|
||||
allow(Settings::Authentication).to receive(:providers).and_return([])
|
||||
allow(Settings::Authentication).to receive(:allow_email_password_registration).and_return(false)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ RSpec.describe "Creator config edit", type: :system, js: true do
|
|||
context "when a creator browses /admin/customization/config" do
|
||||
before do
|
||||
sign_in admin
|
||||
allow(Settings::Authentication).to receive(:invite_only_mode).and_return(false)
|
||||
allow(ForemInstance).to receive(:private?).and_return(false)
|
||||
end
|
||||
|
||||
it "presents all available OAuth providers" do
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ RSpec.describe "Authenticating with Email" do
|
|||
|
||||
context "when community is in invite only mode" do
|
||||
before do
|
||||
allow(Settings::Authentication).to receive(:invite_only_mode).and_return(true)
|
||||
allow(ForemInstance).to receive(:private?).and_return(true)
|
||||
end
|
||||
|
||||
it "doesn't present the authentication option" do
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ RSpec.describe "Authenticating with Facebook" do
|
|||
|
||||
context "when community is in invite only mode" do
|
||||
before do
|
||||
allow(Settings::Authentication).to receive(:invite_only_mode).and_return(true)
|
||||
allow(ForemInstance).to receive(:private?).and_return(true)
|
||||
end
|
||||
|
||||
it "doesn't present the authentication option" do
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ RSpec.describe "Authenticating with GitHub" do
|
|||
|
||||
context "when community is in invite only mode" do
|
||||
before do
|
||||
allow(Settings::Authentication).to receive(:invite_only_mode).and_return(true)
|
||||
allow(ForemInstance).to receive(:private?).and_return(true)
|
||||
end
|
||||
|
||||
it "doesn't present the authentication option" do
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ RSpec.describe "Authenticating with Twitter" do
|
|||
|
||||
context "when community is in invite only mode" do
|
||||
before do
|
||||
allow(Settings::Authentication).to receive(:invite_only_mode).and_return(true)
|
||||
allow(ForemInstance).to receive(:private?).and_return(true)
|
||||
end
|
||||
|
||||
it "doesn't present the authentication option" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue