mirror of
https://github.com/discourse/discourse.git
synced 2025-04-03 05:39:41 +08:00
hard match domains for automatic group membership
This commit is contained in:
parent
088260f053
commit
efd65dcc8c
@ -13,7 +13,7 @@ module Jobs
|
|||||||
|
|
||||||
domains = group.automatic_membership_email_domains.gsub('.', '\.')
|
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
|
group.add(user) rescue ActiveRecord::RecordNotUnique
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -721,7 +721,7 @@ class User < ActiveRecord::Base
|
|||||||
.where("LENGTH(COALESCE(automatic_membership_email_domains, '')) > 0")
|
.where("LENGTH(COALESCE(automatic_membership_email_domains, '')) > 0")
|
||||||
.each do |group|
|
.each do |group|
|
||||||
domains = group.automatic_membership_email_domains.gsub('.', '\.')
|
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
|
group.add(self) rescue ActiveRecord::RecordNotUnique
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user