Change registrations to be disabled by default for new servers (#29353)

This commit is contained in:
Claire 2024-02-22 18:15:59 +01:00 committed by GitHub
parent 4fd22acb4a
commit 328a9b8157
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 28 additions and 17 deletions

View file

@ -145,6 +145,10 @@ delegate(document, '#form_admin_settings_enable_bootstrap_timeline_accounts', 'c
const onChangeRegistrationMode = (target) => { const onChangeRegistrationMode = (target) => {
const enabled = target.value === 'approved'; const enabled = target.value === 'approved';
[].forEach.call(document.querySelectorAll('.form_admin_settings_registrations_mode .warning-hint'), (warning_hint) => {
warning_hint.style.display = target.value === 'open' ? 'inline' : 'none';
});
[].forEach.call(document.querySelectorAll('#form_admin_settings_require_invite_text'), (input) => { [].forEach.call(document.querySelectorAll('#form_admin_settings_require_invite_text'), (input) => {
input.disabled = !enabled; input.disabled = !enabled;
if (enabled) { if (enabled) {

View file

@ -10,9 +10,11 @@
%p.lead= t('admin.settings.registrations.preamble') %p.lead= t('admin.settings.registrations.preamble')
.flash-message= t('admin.settings.registrations.moderation_recommandation')
.fields-row .fields-row
.fields-row__column.fields-row__column-6.fields-group .fields-row__column.fields-row__column-6.fields-group
= f.input :registrations_mode, collection: %w(open approved none), wrapper: :with_label, include_blank: false, label_method: ->(mode) { I18n.t("admin.settings.registrations_mode.modes.#{mode}") } = f.input :registrations_mode, collection: %w(open approved none), wrapper: :with_label, include_blank: false, label_method: ->(mode) { I18n.t("admin.settings.registrations_mode.modes.#{mode}") }, warning_hint: I18n.t('admin.settings.registrations_mode.warning_hint')
.fields-row__column.fields-row__column-6.fields-group .fields-row__column.fields-row__column-6.fields-group
= f.input :require_invite_text, as: :boolean, wrapper: :with_label, disabled: !approved_registrations? = f.input :require_invite_text, as: :boolean, wrapper: :with_label, disabled: !approved_registrations?

View file

@ -764,6 +764,7 @@ en:
disabled: To no one disabled: To no one
users: To logged-in local users users: To logged-in local users
registrations: registrations:
moderation_recommandation: Please make sure you have an adequate and reactive moderation team before you open registrations to everyone!
preamble: Control who can create an account on your server. preamble: Control who can create an account on your server.
title: Registrations title: Registrations
registrations_mode: registrations_mode:
@ -771,6 +772,7 @@ en:
approved: Approval required for sign up approved: Approval required for sign up
none: Nobody can sign up none: Nobody can sign up
open: Anyone can sign up open: Anyone can sign up
warning_hint: We recommend using “Approval required for sign up” unless you are confident your moderation team can handle spam and malicious registrations in a timely fashion.
security: security:
authorized_fetch: Require authentication from federated servers authorized_fetch: Require authentication from federated servers
authorized_fetch_hint: Requiring authentication from federated servers enables stricter enforcement of both user-level and server-level blocks. However, this comes at the cost of a performance penalty, reduces the reach of your replies, and may introduce compatibility issues with some federated services. In addition, this will not prevent dedicated actors from fetching your public posts and accounts. authorized_fetch_hint: Requiring authentication from federated servers enables stricter enforcement of both user-level and server-level blocks. However, this comes at the cost of a performance penalty, reduces the reach of your replies, and may introduce compatibility issues with some federated services. In addition, this will not prevent dedicated actors from fetching your public posts and accounts.

View file

@ -9,7 +9,7 @@ defaults: &defaults
site_terms: '' site_terms: ''
site_contact_username: '' site_contact_username: ''
site_contact_email: '' site_contact_email: ''
registrations_mode: 'open' registrations_mode: 'none'
profile_directory: true profile_directory: true
closed_registrations_message: '' closed_registrations_message: ''
timeline_preview: true timeline_preview: true

View file

@ -142,22 +142,12 @@ RSpec.describe Setting do
context 'when records includes nothing' do context 'when records includes nothing' do
let(:records) { [] } let(:records) { [] }
context 'when default_value is not a Hash' do it 'includes Setting with value of default_value' do
it 'includes Setting with value of default_value' do setting = described_class.all_as_records[key]
setting = described_class.all_as_records[key]
expect(setting).to be_a described_class expect(setting).to be_a described_class
expect(setting).to have_attributes(var: key) expect(setting).to have_attributes(var: key)
expect(setting).to have_attributes(value: 'default_value') expect(setting).to have_attributes(value: default_value)
end
end
context 'when default_value is a Hash' do
let(:default_value) { { 'foo' => 'fuga' } }
it 'returns {}' do
expect(described_class.all_as_records).to eq({})
end
end end
end end
end end

View file

@ -152,6 +152,13 @@ RSpec.configure do |config|
self.use_transactional_tests = false self.use_transactional_tests = false
DatabaseCleaner.cleaning do DatabaseCleaner.cleaning do
# NOTE: we switched registrations mode to closed by default, but the specs
# very heavily rely on having it enabled by default, as it relies on users
# being approved by default except in select cases where explicitly testing
# other registration modes
# Also needs to be set per-example here because of the database cleaner.
Setting.registrations_mode = 'open'
example.run example.run
end end

View file

@ -31,6 +31,12 @@ RSpec.configure do |config|
config.before :suite do config.before :suite do
Rails.application.load_seed Rails.application.load_seed
Chewy.strategy(:bypass) Chewy.strategy(:bypass)
# NOTE: we switched registrations mode to closed by default, but the specs
# very heavily rely on having it enabled by default, as it relies on users
# being approved by default except in select cases where explicitly testing
# other registration modes
Setting.registrations_mode = 'open'
end end
config.after :suite do config.after :suite do