fix: send confirmation email on re-adding agent (#5279)

Send confirmation email after re-adding the agent.

Fixes: #4951
This commit is contained in:
Tejaswini Chile
2022-08-18 13:12:43 +05:30
committed by GitHub
parent 0cd08065d1
commit ea918d9c5a
3 changed files with 21 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ class Api::V1::Accounts::AgentsController < Api::V1::Accounts::BaseController
# TODO: move this to a builder and combine the save account user method into a builder
# ensure the account user association is also created in a single transaction
def create_user
return if @user
return @user.send_confirmation_instructions if @user
@user = User.create!(new_agent_params.slice(:email, :name, :password, :password_confirmation))
end

View File

@@ -5,9 +5,15 @@
<p><%= account_user.inviter.name %>, with <%= account_user.account.name %>, has invited you to try out <%= global_config['BRAND_NAME'] || 'Chatwoot' %>! </p>
<% end %>
<% if @resource.confirmed? %>
<p>You can login to your account through the link below:</p>
<% else %>
<p>You can confirm your account email through the link below:</p>
<% end %>
<% if account_user&.inviter.present? && @resource.unconfirmed_email.blank? %>
<% if @resource.confirmed? %>
<p><%= link_to 'Login to my account', frontend_url('auth/sign_in') %></p>
<% elsif account_user&.inviter.present? && @resource.unconfirmed_email.blank? %>
<p><%= link_to 'Confirm my account', frontend_url('auth/password/edit', reset_password_token: @resource.send(:set_reset_password_token)) %></p>
<% else %>
<p><%= link_to 'Confirm my account', frontend_url('auth/confirmation', confirmation_token: @token) %></p>