Skip to content
Extraits de code Groupes Projets
Valider a6803117 rédigé par MrZYX's avatar MrZYX
Parcourir les fichiers

prevent inviting yourself, #515

parent 07395fb2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -23,6 +23,17 @@ class InvitationsController < Devise::InvitationsController
good_emails, bad_emails = emails.partition{|e| e.try(:match, Devise.email_regexp)}
if good_emails.include?(current_user.email)
if good_emails.length == 1
flash[:error] = I18n.t 'invitations.create.own_address'
redirect_to :back
return
else
bad_emails.push(current_user.email)
good_emails.delete(current_user.email)
end
end
good_emails.each{|e| Resque.enqueue(Job::InviteUserByEmail, current_user.id, e, aspect, message)}
if bad_emails.any?
......
......@@ -238,7 +238,8 @@ en:
rejected: "The following email addresses had problems: "
no_more: "You have no more invitations."
already_sent: "You already invited this person."
already_contacts: "You are already connected with this person"
already_contacts: "You are already connected with this person"
own_address: "You can't send an invitation to your own address."
new:
invite_someone_to_join: "Invite someone to join Diaspora!"
if_they_accept_info: "if they accept, they will be added to the aspect you invited them."
......
......@@ -61,6 +61,15 @@ describe InvitationsController do
post :create, :user => @invite
response.should redirect_to("http://test.host/cats/foo")
end
it 'strips out your own email' do
lambda {
post :create, :user => @invite.merge(:email => @user.email)
}.should_not change(User, :count)
Resque.should_receive(:enqueue).once
post :create, :user => @invite.merge(:email => "hello@example.org, #{@user.email}")
end
end
describe "#update" do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter