Merge pull request #2864 from techAPJ/patch-3
FIX: invite email should be verified against `email_domains_blacklist`
This commit is contained in:
commit
e8637344c3
|
@ -98,7 +98,13 @@ module Jobs
|
||||||
email = csv_info[0]
|
email = csv_info[0]
|
||||||
group_ids = get_group_ids(csv_info[1], csv_line_number)
|
group_ids = get_group_ids(csv_info[1], csv_line_number)
|
||||||
topic = get_topic(csv_info[2], csv_line_number)
|
topic = get_topic(csv_info[2], csv_line_number)
|
||||||
Invite.invite_by_email(email, @current_user, topic, group_ids)
|
begin
|
||||||
|
Invite.invite_by_email(email, @current_user, topic, group_ids)
|
||||||
|
rescue => e
|
||||||
|
log "Error inviting '#{email}' -- #{e}"
|
||||||
|
@sent -= 1
|
||||||
|
@failed += 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def log(message)
|
def log(message)
|
||||||
|
|
|
@ -10,6 +10,7 @@ class Invite < ActiveRecord::Base
|
||||||
has_many :topic_invites
|
has_many :topic_invites
|
||||||
has_many :topics, through: :topic_invites, source: :topic
|
has_many :topics, through: :topic_invites, source: :topic
|
||||||
validates_presence_of :invited_by_id
|
validates_presence_of :invited_by_id
|
||||||
|
validates :email, email: true
|
||||||
|
|
||||||
before_create do
|
before_create do
|
||||||
self.invite_key ||= SecureRandom.hex
|
self.invite_key ||= SecureRandom.hex
|
||||||
|
|
|
@ -21,6 +21,21 @@ describe Invite do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'email validators' do
|
||||||
|
let(:coding_horror) { Fabricate(:coding_horror) }
|
||||||
|
let(:invite) { Invite.create(email: "test@mailinator.com", invited_by: coding_horror) }
|
||||||
|
|
||||||
|
it "should not allow an invite with blacklisted email" do
|
||||||
|
invite.should_not be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should allow an invite with non-blacklisted email" do
|
||||||
|
invite = Fabricate(:invite, email: "test@mail.com", invited_by: coding_horror)
|
||||||
|
invite.should be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
context '#create' do
|
context '#create' do
|
||||||
|
|
||||||
context 'saved' do
|
context 'saved' do
|
||||||
|
|
Loading…
Reference in New Issue