From e1e18aa0aa6f45e0831811b88f63e481c3b4d75a Mon Sep 17 00:00:00 2001 From: Julianna Tetreault <32834804+juliannatetreault@users.noreply.github.com> Date: Mon, 12 Jul 2021 14:14:43 -0600 Subject: [PATCH] [15-Minute Fix] Ensure "Locked Screen" Checkbox Conditionally Renders (#14161) * Uses Settings::UserExperience.public to conditionally render btn * Updates landing page-related specs to account for private forem * Uses Settings::UserExperience in place of ForemInstance in admin_creates_new_page_spec.rb * Reverts Settings::UserExperience.public? changes throughout codebase - Removes any changes to ForemInstance.private? - Adds a new helper method, self.invitation_only? - Updates self.private? logic * Updates landing page specs and reverts unnecessary changes - Reverts any changes that removed the check for ForemInstance.private? - Updates landingPage.spec.js to use findByRole rather than findByText * Reverts a change to admin_manages_pages_spec.rb * Updates landingPage.spec.js per PR review comment * Updates #private_forem_or_no_enabled_auth_options and spec * Uses .invite_only? in _providers_registration_form.html.erb * Adjusts authenticationSection.spec.js to test that FB is enabled * Updates necessary specs to check .invitation_only? * Consistently uses invite_only_mode_or_no_enabled_auth_options - Updates all necessary places within the codebase to use reverted method name, invite_only_mode_or_no_enabled_auth_providers - Updates #self.enabled to check ForemInstance.invitation_only? rather than ForemInstance.private? - Reverts change to Facebook assertion within authenticationSection e2e test * Removes superfluous .to from authenticationSection.spec.js --- app/helpers/authentication_helper.rb | 10 +++++----- app/models/forem_instance.rb | 6 +++++- app/services/authentication/providers.rb | 2 +- .../settings/forms/_authentication.html.erb | 4 ++-- .../registrations/_registration_form.html.erb | 2 +- .../_providers_registration_form.html.erb | 2 +- .../config/authenticationSection.spec.js | 17 ++++++++++------ .../adminFlows/pages/landingPage.spec.js | 20 +++++++++++-------- spec/system/admin/admin_manages_pages_spec.rb | 8 ++++---- .../user_logs_in_with_email_spec.rb | 4 ++-- .../user_logs_in_with_facebook_spec.rb | 4 ++-- .../user_logs_in_with_github_spec.rb | 4 ++-- .../user_logs_in_with_twitter_spec.rb | 4 ++-- 13 files changed, 50 insertions(+), 37 deletions(-) diff --git a/app/helpers/authentication_helper.rb b/app/helpers/authentication_helper.rb index b6041f003..5b80d94f6 100644 --- a/app/helpers/authentication_helper.rb +++ b/app/helpers/authentication_helper.rb @@ -45,22 +45,22 @@ module AuthenticationHelper Settings::General.waiting_on_first_user end - def private_forem_or_no_enabled_auth_options - ForemInstance.private? || + def invite_only_mode_or_no_enabled_auth_options + ForemInstance.invitation_only? || (authentication_enabled_providers.none? && !Settings::Authentication.allow_email_password_registration) end def tooltip_class_on_auth_provider_enablebtn - private_forem_or_no_enabled_auth_options ? "crayons-tooltip" : "" + invite_only_mode_or_no_enabled_auth_options ? "crayons-tooltip" : "" end def disabled_attr_on_auth_provider_enable_btn - private_forem_or_no_enabled_auth_options ? "disabled" : "" + invite_only_mode_or_no_enabled_auth_options ? "disabled" : "" end def tooltip_text_email_or_auth_provider_btns - if private_forem_or_no_enabled_auth_options + if invite_only_mode_or_no_enabled_auth_options "You cannot do this until you disable Invite Only Mode" else "" diff --git a/app/models/forem_instance.rb b/app/models/forem_instance.rb index 7ed1e891c..5d29e127b 100644 --- a/app/models/forem_instance.rb +++ b/app/models/forem_instance.rb @@ -28,7 +28,11 @@ class ForemInstance (Settings::SMTP.user_name.present? && Settings::SMTP.password.present?) || ENV["SENDGRID_API_KEY"].present? end - def self.private? + def self.invitation_only? Settings::Authentication.invite_only_mode? end + + def self.private? + !Settings::UserExperience.public? + end end diff --git a/app/services/authentication/providers.rb b/app/services/authentication/providers.rb index 330fa16f4..082a6409a 100644 --- a/app/services/authentication/providers.rb +++ b/app/services/authentication/providers.rb @@ -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 ForemInstance.private? + return [] if ForemInstance.invitation_only? Settings::Authentication.providers.map(&:to_sym).sort end diff --git a/app/views/admin/settings/forms/_authentication.html.erb b/app/views/admin/settings/forms/_authentication.html.erb index 84eb05d1b..073ac74bf 100644 --- a/app/views/admin/settings/forms/_authentication.html.erb +++ b/app/views/admin/settings/forms/_authentication.html.erb @@ -13,10 +13,10 @@ General settings