From 5f60d86efeb36906ac2a8f2808b0f503d053ca49 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 22 Jul 2022 23:44:42 +0200 Subject: [PATCH] Make forbidden screen names configurable --- app/validators/screen_name_validator.rb | 5 +---- config/justask.yml.example | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/validators/screen_name_validator.rb b/app/validators/screen_name_validator.rb index 815d4faa..8fea65bb 100644 --- a/app/validators/screen_name_validator.rb +++ b/app/validators/screen_name_validator.rb @@ -1,10 +1,7 @@ # frozen_string_literal: true class ScreenNameValidator < ActiveModel::EachValidator - FORBIDDEN_SCREEN_NAMES = %w[justask_admin retrospring_admin admin justask retrospring about public - notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator - siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding - pixeidesu plxeldesu plxeidesu terms privacy linkfilter feedback].freeze + FORBIDDEN_SCREEN_NAMES = APP_CONFIG["forbidden_screen_names"].freeze FORBIDDEN_SCREEN_NAME_REGEXPS = [/wreciap\z/i].freeze def validate_each(record, attribute, value) diff --git a/config/justask.yml.example b/config/justask.yml.example index f1a50127..b5e33f98 100644 --- a/config/justask.yml.example +++ b/config/justask.yml.example @@ -9,6 +9,23 @@ email_from: "noreply@justask.rrerr.net" # Name of the "Anonymous" user. (e.g. "Anonymous Coward", "Arno Nym", "Mr. X", ...) anonymous_name: "Anonymous" +forbidden_screen_names: + - justask_admin + - retrospring_admin + - admin + - justask + - retrospring + - moderation + - moderator + - mod + - administrator + - siteadmin + - site_admin + - help + - retro_spring + - retroospring + - retrosprlng + # Text shown on the about page (Markdown can be used here) about: | # About