diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 30671b02332..6b2a4ef2175 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -2344,6 +2344,7 @@ en: create_revision_on_bulk_topic_moves: "Create revision for first posts when topics are moved into a new category in bulk." allow_changing_staged_user_tracking: "Allow a staged user's category and tag notification preferences to be changed by an admin user." + use_email_for_username_and_name_suggestions: "Use the first part of email addresses for username and name suggestions. Note that this makes it easier for the public to guess full user email addresses (because a large proportion of people share common services like `gmail.com`)." errors: invalid_css_color: "Invalid color. Enter a color name or hex value." diff --git a/config/site_settings.yml b/config/site_settings.yml index 560ad131b80..897a2c6d0f1 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -686,7 +686,6 @@ users: default: 2000 hidden: true use_email_for_username_and_name_suggestions: - hidden: true default: false groups: diff --git a/db/migrate/20220130192155_set_use_email_for_username_and_name_suggestions_on_existing_sites.rb b/db/migrate/20220130192155_set_use_email_for_username_and_name_suggestions_on_existing_sites.rb new file mode 100644 index 00000000000..22b19c60dbb --- /dev/null +++ b/db/migrate/20220130192155_set_use_email_for_username_and_name_suggestions_on_existing_sites.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class SetUseEmailForUsernameAndNameSuggestionsOnExistingSites < ActiveRecord::Migration[6.1] + def up + result = execute <<~SQL + SELECT created_at + FROM schema_migration_details + ORDER BY created_at + LIMIT 1 + SQL + + # make setting enabled for existing sites + if result.first['created_at'].to_datetime < 1.hour.ago + execute <<~SQL + INSERT INTO site_settings(name, data_type, value, created_at, updated_at) + VALUES('use_email_for_username_and_name_suggestions', 5, 't', NOW(), NOW()) + ON CONFLICT (name) DO NOTHING + SQL + end + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end