hard match domains for automatic group membership

This commit is contained in:
Régis Hanol 2015-01-26 23:17:29 +01:00
parent 088260f053
commit efd65dcc8c
2 changed files with 2 additions and 2 deletions

View File

@ -13,7 +13,7 @@ module Jobs
domains = group.automatic_membership_email_domains.gsub('.', '\.')
User.where("email ~* '@(#{domains})'").find_each do |user|
User.where("email ~* '@(#{domains})$'").find_each do |user|
group.add(user) rescue ActiveRecord::RecordNotUnique
end
end

View File

@ -721,7 +721,7 @@ class User < ActiveRecord::Base
.where("LENGTH(COALESCE(automatic_membership_email_domains, '')) > 0")
.each do |group|
domains = group.automatic_membership_email_domains.gsub('.', '\.')
if self.email =~ Regexp.new("@(#{domains})", true)
if self.email =~ Regexp.new("@(#{domains})$", true)
group.add(self) rescue ActiveRecord::RecordNotUnique
end
end