Skip to content
Extraits de code Groupes Projets
Valider 0c12471f rédigé par Paul Spieker's avatar Paul Spieker
Parcourir les fichiers

add username blacklist

parent a99d9927
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
validates :username, :presence => true, :uniqueness => true
validates_format_of :username, :with => /\A[A-Za-z0-9_]+\z/
validates_length_of :username, :maximum => 32
validates_exclusion_of :username, :in => USERNAME_BLACKLIST
validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES
validates_format_of :unconfirmed_email, :with => Devise.email_regexp, :allow_blank => true
......
......@@ -27,6 +27,10 @@ else
RTL_LANGUAGES = []
end
# Blacklist of usernames
USERNAME_BLACKLIST = ['admin', 'administrator', 'hostmaster', 'info', 'postmaster', 'root', 'ssladmin',
'ssladministrator', 'sslwebmaster', 'sysadmin', 'webmaster', 'support', 'contact']
# Initialize the rails application
Diaspora::Application.initialize!
......
......@@ -151,6 +151,13 @@ describe User do
alice.username = "hexagooooooooooooooooooooooooooon"
alice.should_not be_valid
end
it "cannot be one of the blacklist names" do
['hostmaster', 'postmaster', 'root', 'webmaster'].each do |username|
alice.username = username
alice.should_not be_valid
end
end
end
describe "of email" do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter