diff --git a/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js index 4c81e97023c3f..e6c8e608d9a6f 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/create-account-external-test.js @@ -25,7 +25,8 @@ acceptance("Create Account - external auth", function (needs) { document.getElementById("data-authentication").remove(); }); - test("when skip is disabled (default)", async function (assert) { + test("when skip is disabled", async function (assert) { + this.siteSettings.auth_skip_create_confirm = false; await visit("/"); assert.dom(".signup-fullpage").exists("it shows the signup page"); @@ -37,8 +38,7 @@ acceptance("Create Account - external auth", function (needs) { .doesNotExist("it does not show the associate link"); }); - test("when skip is enabled", async function (assert) { - this.siteSettings.auth_skip_create_confirm = true; + test("when skip is enabled (default)", async function (assert) { await visit("/"); assert.dom(".signup-fullpage").exists("it shows the signup page"); @@ -58,6 +58,7 @@ acceptance("Create account - with associate link", function (needs) { }); test("displays associate link when allowed", async function (assert) { + this.siteSettings.auth_skip_create_confirm = false; await visit("/"); assert.dom(".signup-fullpage").exists("it shows the signup page"); diff --git a/config/site_settings.yml b/config/site_settings.yml index de3f089733947..eee573a8b96b5 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -665,7 +665,7 @@ login: regex: "^[a-zA-Z0-9_=\\.]+$" secret: true auth_skip_create_confirm: - default: false + default: true client: true auth_immediately: default: true diff --git a/db/migrate/20250604181345_disable_auth_skip_create_confirm_existing_sites.rb b/db/migrate/20250604181345_disable_auth_skip_create_confirm_existing_sites.rb new file mode 100644 index 0000000000000..8229b77e3b7e8 --- /dev/null +++ b/db/migrate/20250604181345_disable_auth_skip_create_confirm_existing_sites.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class DisableAuthSkipCreateConfirmExistingSites < ActiveRecord::Migration[7.2] + def up + execute <<~SQL if Migration::Helpers.existing_site? + INSERT INTO site_settings(name, data_type, value, created_at, updated_at) + VALUES('auth_skip_create_confirm', 5, 'f', NOW(), NOW()) + ON CONFLICT (name) DO NOTHING + SQL + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/spec/system/social_authentication_spec.rb b/spec/system/social_authentication_spec.rb index 30d391fd351bc..8979b22993a0d 100644 --- a/spec/system/social_authentication_spec.rb +++ b/spec/system/social_authentication_spec.rb @@ -6,7 +6,11 @@ let(:login_form) { PageObjects::Pages::Login.new } let(:signup_form) { PageObjects::Pages::Signup.new } - before { OmniAuth.config.test_mode = true } + before do + OmniAuth.config.test_mode = true + SiteSetting.auth_skip_create_confirm = false + SiteSetting.full_name_requirement = "optional_at_signup" + end end shared_examples "social authentication scenarios" do @@ -269,19 +273,35 @@ end context "when skipping the signup form" do - before do - SiteSetting.enable_google_oauth2_logins = true - SiteSetting.auth_skip_create_confirm = true - end + before { SiteSetting.auth_skip_create_confirm = true } after { reset_omniauth_config(:google_oauth2) } - it "creates the account directly" do + it "works with Google" do + SiteSetting.enable_google_oauth2_logins = true mock_google_auth visit("/") signup_form.open.click_social_button("google_oauth2") expect(page).to have_css(".header-dropdown-toggle.current-user") end + + it "works with Github" do + SiteSetting.enable_github_logins = true + mock_github_auth + visit("/") + + signup_form.open.click_social_button("github") + expect(page).to have_css(".header-dropdown-toggle.current-user") + end + + it "works with Discord" do + SiteSetting.enable_discord_logins = true + mock_discord_auth + visit("/") + + signup_form.open.click_social_button("discord") + expect(page).to have_css(".header-dropdown-toggle.current-user") + end end context "when there is only one external login method enabled" do @@ -502,13 +522,11 @@ end describe "Social authentication", type: :system do - before { SiteSetting.full_name_requirement = "optional_at_signup" } - - context "when fullpage desktop" do + context "when desktop" do include_examples "social authentication scenarios" end - context "when fullpage mobile", mobile: true do + context "when mobile", mobile: true do include_examples "social authentication scenarios" end end