Add ability to block words in usernames (#35407)
This commit is contained in:
16
app/views/admin/username_blocks/_form.html.haml
Normal file
16
app/views/admin/username_blocks/_form.html.haml
Normal file
@@ -0,0 +1,16 @@
|
||||
.fields-group
|
||||
= form.input :username,
|
||||
wrapper: :with_block_label,
|
||||
input_html: { autocomplete: 'new-password', pattern: '[a-zA-Z0-9_]+', maxlength: Account::USERNAME_LENGTH_LIMIT }
|
||||
|
||||
.fields-group
|
||||
= form.input :comparison,
|
||||
as: :select,
|
||||
wrapper: :with_block_label,
|
||||
collection: %w(equals contains),
|
||||
include_blank: false,
|
||||
label_method: ->(type) { I18n.t(type, scope: 'admin.username_blocks.comparison') }
|
||||
|
||||
.fields-group
|
||||
= form.input :allow_with_approval,
|
||||
wrapper: :with_label
|
||||
12
app/views/admin/username_blocks/_username_block.html.haml
Normal file
12
app/views/admin/username_blocks/_username_block.html.haml
Normal file
@@ -0,0 +1,12 @@
|
||||
.batch-table__row
|
||||
%label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox
|
||||
= f.check_box :username_block_ids, { multiple: true, include_hidden: false }, username_block.id
|
||||
.sr-only= username_block.username
|
||||
.batch-table__row__content.pending-account
|
||||
.pending-account__header
|
||||
= t(username_block.exact? ? 'admin.username_blocks.matches_exactly_html' : 'admin.username_blocks.contains_html', string: content_tag(:samp, link_to(username_block.username, edit_admin_username_block_path(username_block))))
|
||||
%br/
|
||||
- if username_block.allow_with_approval?
|
||||
= t('admin.email_domain_blocks.allow_registrations_with_approval')
|
||||
- else
|
||||
= t('admin.username_blocks.block_registrations')
|
||||
10
app/views/admin/username_blocks/edit.html.haml
Normal file
10
app/views/admin/username_blocks/edit.html.haml
Normal file
@@ -0,0 +1,10 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.username_blocks.edit.title')
|
||||
|
||||
= simple_form_for @username_block, url: admin_username_block_path(@username_block) do |form|
|
||||
= render 'shared/error_messages', object: @username_block
|
||||
|
||||
= render form
|
||||
|
||||
.actions
|
||||
= form.button :button, t('generic.save_changes'), type: :submit
|
||||
26
app/views/admin/username_blocks/index.html.haml
Normal file
26
app/views/admin/username_blocks/index.html.haml
Normal file
@@ -0,0 +1,26 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.username_blocks.title')
|
||||
|
||||
- content_for :heading_actions do
|
||||
= link_to t('admin.username_blocks.add_new'), new_admin_username_block_path, class: 'button'
|
||||
|
||||
= form_with model: @form, url: batch_admin_username_blocks_path do |f|
|
||||
= hidden_field_tag :page, params[:page] || 1
|
||||
|
||||
.batch-table
|
||||
.batch-table__toolbar
|
||||
%label.batch-table__toolbar__select.batch-checkbox-all
|
||||
= check_box_tag :batch_checkbox_all, nil, false
|
||||
.batch-table__toolbar__actions
|
||||
= f.button safe_join([material_symbol('close'), t('admin.username_blocks.delete')]),
|
||||
class: 'table-action-link',
|
||||
data: { confirm: t('admin.reports.are_you_sure') },
|
||||
name: :delete,
|
||||
type: :submit
|
||||
.batch-table__body
|
||||
- if @username_blocks.empty?
|
||||
= nothing_here 'nothing-here--under-tabs'
|
||||
- else
|
||||
= render partial: 'username_block', collection: @username_blocks, locals: { f: f }
|
||||
|
||||
= paginate @username_blocks
|
||||
10
app/views/admin/username_blocks/new.html.haml
Normal file
10
app/views/admin/username_blocks/new.html.haml
Normal file
@@ -0,0 +1,10 @@
|
||||
- content_for :page_title do
|
||||
= t('admin.username_blocks.new.title')
|
||||
|
||||
= simple_form_for @username_block, url: admin_username_blocks_path do |form|
|
||||
= render 'shared/error_messages', object: @username_block
|
||||
|
||||
= render form
|
||||
|
||||
.actions
|
||||
= form.button :button, t('admin.username_blocks.new.create'), type: :submit
|
||||
Reference in New Issue
Block a user