Do not allow spam users to be created

This commit is contained in:
Georg Gadinger 2018-07-27 20:27:40 +02:00
parent 66400c87dd
commit a5d689e76c
1 changed files with 4 additions and 0 deletions

View File

@ -3,10 +3,14 @@ class ScreenNameValidator < ActiveModel::EachValidator
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)
FORBIDDEN_SCREEN_NAME_REGEXPS = [/wreciap\z/i]
def validate_each(record, attribute, value)
if FORBIDDEN_SCREEN_NAMES.include? value.downcase
record.errors[attribute] << "Thou shalt not use this username! Please choose another one."
end
if FORBIDDEN_SCREEN_NAME_REGEXPS.any? { |regexp| value.downcase =~ regexp }
record.errors[attribute] << "Registration is tempoarily disabled for new users."
end
end
end