Skip to content

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

FEATURE: Bump enable_local_logins_via_code upcoming change to beta (#42040)

discoursebotb7b153997033
diff --git a/config/site_settings.yml b/config/site_settings.yml
index f36a365c58e..e7abea37b25 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -694,7 +694,7 @@ login:
- enable_local_logins
- enable_local_logins_via_email
upcoming_change:
- status: "alpha"
+ status: "beta"
impact: "feature,all_members"
learn_more_url: "https://meta.discourse.org/t/-/407068"
permanent_warning: false
diff --git a/plugins/discourse-captcha/spec/system/signup_with_captcha_spec.rb b/plugins/discourse-captcha/spec/system/signup_with_captcha_spec.rb
index 0582320aed0..60b7b091896 100644
--- a/plugins/discourse-captcha/spec/system/signup_with_captcha_spec.rb
+++ b/plugins/discourse-captcha/spec/system/signup_with_captcha_spec.rb
@@ -7,6 +7,10 @@ RSpec.describe "Signup with captcha" do
before do
SiteSetting.enable_local_logins = true
SiteSetting.discourse_captcha_enabled = true
+
+ # The captcha outlet only exists on the password signup form, which the
+ # code-based form replaces when enable_local_logins_via_code is on.
+ SiteSetting.enable_local_logins_via_code = false
end
context "with hCaptcha", allow_network: %w[hcaptcha.com *.hcaptcha.com] do
diff --git a/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb b/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb
index d6ccc21db98..6f04fe2b2ce 100644
--- a/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb
+++ b/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb
@@ -30,6 +30,10 @@ RSpec.describe "Discobot welcome post" do
Fabricate(:invite, invited_by: Fabricate(:admin), email: "[email protected]")
end
+ # Redeeming through the legacy form, which the email code flow replaces
+ # when enable_local_logins_via_code is on.
+ before { SiteSetting.enable_local_logins_via_code = false }
+
it "delays the welcome post until the user logs in" do
expect do
put "/invites/show/#{invite.invite_key}.json",
diff --git a/spec/lib/upcoming_changes_spec.rb b/spec/lib/upcoming_changes_spec.rb
index 5f704533cd0..404944a4962 100644
--- a/spec/lib/upcoming_changes_spec.rb
+++ b/spec/lib/upcoming_changes_spec.rb
@@ -1335,6 +1335,10 @@ RSpec.describe UpcomingChanges do
end
describe ".should_display_enable_local_logins_via_code?" do
+ # Pin the promotion threshold above the change's status so these specs
+ # exercise the prerequisite branch rather than the auto-promoted one.
+ before { SiteSetting.promote_upcoming_changes_on_status = :never }
+
it "returns true when local logins via email are possible" do
expect(
UpcomingChanges::ConditionalDisplay.should_display?(:enable_local_logins_via_code),
diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rb
index 0f3a1f98873..bca2f0e8472 100644
--- a/spec/requests/invites_controller_spec.rb
+++ b/spec/requests/invites_controller_spec.rb
@@ -7,6 +7,11 @@ RSpec.describe InvitesController do
describe "#show" do
fab!(:invite)
+ # These cover the legacy invite flow, which the email code flow replaces
+ # when enable_local_logins_via_code is on. Examples that exercise the code
+ # flow enable it for themselves.
+ before { SiteSetting.enable_local_logins_via_code = false }
+
it "shows the accept invite page" do
get "/invites/#{invite.invite_key}"
expect(response.status).to eq(200)
@@ -1351,6 +1356,11 @@ RSpec.describe InvitesController do
end
describe "#perform_accept_invitation" do
+ # These cover the legacy invite flow, which the email code flow replaces
+ # when enable_local_logins_via_code is on. Examples that exercise the code
+ # flow enable it for themselves.
+ before { SiteSetting.enable_local_logins_via_code = false }
+
context "when anonymous invite acceptance uses email codes" do
fab!(:invite)
diff --git a/spec/system/create_invite_with_roles_spec.rb b/spec/system/create_invite_with_roles_spec.rb
index 51365a82d5e..49378687db6 100644
--- a/spec/system/create_invite_with_roles_spec.rb
+++ b/spec/system/create_invite_with_roles_spec.rb
@@ -12,7 +12,13 @@ describe "Creating invites with roles" do
let(:invite_form) { PageObjects::Pages::InviteForm.new }
let(:cdp) { PageObjects::CDP.new }
- before { SiteSetting.enable_invite_modal_with_roles = true }
+ before do
+ SiteSetting.enable_invite_modal_with_roles = true
+
+ # Redemption here goes through the password invite form, which the email
+ # code flow replaces when enable_local_logins_via_code is on.
+ SiteSetting.enable_local_logins_via_code = false
+ end
def open_invite_modal_for(current_user)
user_invited_pending_page.visit(current_user)
diff --git a/spec/system/login_spec.rb b/spec/system/login_spec.rb
index 380bdea83c3..b49144373e9 100644
--- a/spec/system/login_spec.rb
+++ b/spec/system/login_spec.rb
@@ -112,6 +112,10 @@ shared_examples "login scenarios" do
end
context "with login link" do
+ # The email login link is replaced by the code login flow when
+ # enable_local_logins_via_code is on, which has its own spec.
+ before { SiteSetting.enable_local_logins_via_code = false }
+
it "can login" do
login_form.open.fill_username("john").email_login_link
@@ -362,28 +366,34 @@ shared_examples "login scenarios" do
expect(page).to have_css(".header-dropdown-toggle.current-user")
end
- it "can login with login link and totp" do
- login_form.open.fill_username("john").email_login_link
+ context "with login link" do
+ # The email login link is replaced by the code login flow when
+ # enable_local_logins_via_code is on, which has its own spec.
+ before { SiteSetting.enable_local_logins_via_code = false }
- login_link = wait_for_email_link(user, :email_login)
- visit login_link
- totp = ROTP::TOTP.new(user_second_factor.data).now
- find(".second-factor-token-input").fill_in(with: totp)
- find(".email-login-form .btn-primary").click
+ it "can login with login link and totp" do
+ login_form.open.fill_username("john").email_login_link
- expect(page).to have_css(".header-dropdown-toggle.current-user")
- end
+ login_link = wait_for_email_link(user, :email_login)
+ visit login_link
+ totp = ROTP::TOTP.new(user_second_factor.data).now
+ find(".second-factor-token-input").fill_in(with: totp)
+ find(".email-login-form .btn-primary").click
- it "can login with login link and backup code" do
- login_form.open.fill_username("john").email_login_link
+ expect(page).to have_css(".header-dropdown-toggle.current-user")
+ end
- login_link = wait_for_email_link(user, :email_login)
- visit login_link
- find(".toggle-second-factor-method").click
- find(".second-factor-token-input").fill_in(with: "iAmValidBackupCode")
- find(".email-login-form .btn-primary").click
+ it "can login with login link and backup code" do
+ login_form.open.fill_username("john").email_login_link
- expect(page).to have_css(".header-dropdown-toggle.current-user")
+ login_link = wait_for_email_link(user, :email_login)
+ visit login_link
+ find(".toggle-second-factor-method").click
+ find(".second-factor-token-input").fill_in(with: "iAmValidBackupCode")
+ find(".email-login-form .btn-primary").click
+
+ expect(page).to have_css(".header-dropdown-toggle.current-user")
+ end
end
it "can reset password with TOTP" do
diff --git a/spec/system/signup_spec.rb b/spec/system/signup_spec.rb
index 24ca617e8fe..e08b081b5c2 100644
--- a/spec/system/signup_spec.rb
+++ b/spec/system/signup_spec.rb
@@ -9,6 +9,10 @@ shared_examples "signup scenarios" do
let(:invite) { Fabricate(:invite) }
let(:topic) { Fabricate(:topic, title: "Super cool topic") }
+ # These cover the password signup form. The code-based form replaces it when
+ # enable_local_logins_via_code is on, and has its own spec.
+ before { SiteSetting.enable_local_logins_via_code = false }
+
context "when anyone can create an account" do
before { Jobs.run_immediately! }