FIX: always send password reset email when accepting invite if password is not set
This commit is contained in:
parent
60f1169077
commit
1c23aedccf
|
@ -226,6 +226,8 @@ class InvitesController < ApplicationController
|
|||
if user.has_password?
|
||||
email_token = user.email_tokens.create(email: user.email)
|
||||
Jobs.enqueue(:critical_user_email, type: :signup, user_id: user.id, email_token: email_token.token)
|
||||
elsif !SiteSetting.enable_sso && SiteSetting.enable_local_logins
|
||||
Jobs.enqueue(:invite_password_instructions_email, username: user.username)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ InviteRedeemer = Struct.new(:invite, :username, :name, :password) do
|
|||
add_user_to_groups
|
||||
send_welcome_message
|
||||
notify_invitee
|
||||
send_password_instructions
|
||||
delete_duplicate_invites
|
||||
end
|
||||
|
||||
|
@ -120,12 +119,6 @@ InviteRedeemer = Struct.new(:invite, :username, :name, :password) do
|
|||
end
|
||||
end
|
||||
|
||||
def send_password_instructions
|
||||
if !SiteSetting.enable_sso && SiteSetting.enable_local_logins && !invited_user.has_password?
|
||||
Jobs.enqueue(:invite_password_instructions_email, username: invited_user.username)
|
||||
end
|
||||
end
|
||||
|
||||
def notify_invitee
|
||||
if inviter = invite.invited_by
|
||||
inviter.notifications.create(notification_type: Notification.types[:invitee_accepted],
|
||||
|
|
|
@ -223,7 +223,7 @@ describe InvitesController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'welcome message and activation email' do
|
||||
context '.post_process_invite' do
|
||||
before do
|
||||
Invite.any_instance.stubs(:redeem).returns(user)
|
||||
Jobs.expects(:enqueue).with(:invite_email, has_key(:invite_id))
|
||||
|
@ -233,11 +233,13 @@ describe InvitesController do
|
|||
it 'sends a welcome message if set' do
|
||||
user.send_welcome_message = true
|
||||
user.expects(:enqueue_welcome_message).with('welcome_invite')
|
||||
Jobs.expects(:enqueue).with(:invite_password_instructions_email, has_entries(username: user.username))
|
||||
xhr :put, :perform_accept_invitation, id: invite.invite_key, format: :json
|
||||
end
|
||||
|
||||
it "doesn't send a welcome message if not set" do
|
||||
it "sends password reset email if password is not set" do
|
||||
user.expects(:enqueue_welcome_message).with('welcome_invite').never
|
||||
Jobs.expects(:enqueue).with(:invite_password_instructions_email, has_entries(username: user.username))
|
||||
xhr :put, :perform_accept_invitation, id: invite.invite_key, format: :json
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ describe InviteRedeemer do
|
|||
SiteSetting.must_approve_users = true
|
||||
inviter = invite.invited_by
|
||||
inviter.admin = true
|
||||
Jobs.expects(:enqueue).with(:invite_password_instructions_email, has_entries(username: username))
|
||||
user = invite_redeemer.redeem
|
||||
|
||||
expect(user.name).to eq(name)
|
||||
|
|
Loading…
Reference in New Issue