FEATURE: make the use_email_for_username_and_name_suggestions setting visible and on by default on existing sites (#15751)

This commit is contained in:
Andrei Prigorshnev 2022-02-01 11:55:17 +01:00 committed by GitHub
parent c46b55dc3b
commit dad2e5e513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View File

@ -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."

View File

@ -686,7 +686,6 @@ users:
default: 2000
hidden: true
use_email_for_username_and_name_suggestions:
hidden: true
default: false
groups:

View File

@ -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