mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
FIX: invite email should be verified against email_domains_blacklist
This commit is contained in:
parent
f834a5fe4e
commit
430967c354
|
@ -98,7 +98,13 @@ module Jobs
|
|||
email = csv_info[0]
|
||||
group_ids = get_group_ids(csv_info[1], 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
|
||||
|
||||
def log(message)
|
||||
|
|
|
@ -10,6 +10,7 @@ class Invite < ActiveRecord::Base
|
|||
has_many :topic_invites
|
||||
has_many :topics, through: :topic_invites, source: :topic
|
||||
validates_presence_of :invited_by_id
|
||||
validates :email, email: true
|
||||
|
||||
before_create do
|
||||
self.invite_key ||= SecureRandom.hex
|
||||
|
|
|
@ -21,6 +21,21 @@ describe Invite do
|
|||
|
||||
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 'saved' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user