diff options
author | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-08-05 12:01:42 +0200 |
---|---|---|
committer | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-08-05 12:01:42 +0200 |
commit | 29122249f8cc197cc4e5fa6ec3a70d3c59362ad9 (patch) | |
tree | 7a415d4d011f6e7282bffa6a31c278bbd85538ff /sonar-server/src/main/webapp | |
parent | 52ae0976c90c6f4d47ce84cd5c3b6d3529c70e0e (diff) | |
download | sonarqube-29122249f8cc197cc4e5fa6ec3a70d3c59362ad9.tar.gz sonarqube-29122249f8cc197cc4e5fa6ec3a70d3c59362ad9.zip |
SONAR-4457 Prevent admins from creating a group of users named 'Anyone'
Diffstat (limited to 'sonar-server/src/main/webapp')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/models/group.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/group.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/group.rb index b9cba9ca15c..f8ac4a0ee38 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/group.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/group.rb @@ -19,6 +19,8 @@ # class Group < ActiveRecord::Base + ANYONE = 'anyone' + has_and_belongs_to_many :users has_many :group_roles, :dependent => :delete_all @@ -26,6 +28,7 @@ class Group < ActiveRecord::Base validates_length_of :name, :within => 1..255 validates_length_of :description, :within => 0..200 validates_uniqueness_of :name + validate :name_cant_be_anyone # all the users that are NOT members of this group def available_users @@ -45,4 +48,8 @@ class Group < ActiveRecord::Base return 1 if other.nil? || other.name.nil? name.downcase<=>other.name.downcase end + + def name_cant_be_anyone + errors.add(:name, 'cannot be "Anyone" as this is a reserved group name.') if name && name.downcase == ANYONE + end end |