From 94b590b7382bc06242f269f2282c2627f8cbdb21 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
<41898282+github-actions[bot]@users.noreply.github.com>
Date: Fri, 13 Dec 2024 20:07:43 +0530
Subject: [PATCH] feat(CE): login invited user fix (#695) (#526)
Co-authored-by: Basil V Bose
---
server/app/mailers/devise_mailer.rb | 1 +
.../app/views/devise/mailer/invitation_instructions.html.erb | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/server/app/mailers/devise_mailer.rb b/server/app/mailers/devise_mailer.rb
index 4f9f415f..80870b80 100644
--- a/server/app/mailers/devise_mailer.rb
+++ b/server/app/mailers/devise_mailer.rb
@@ -6,6 +6,7 @@ class DeviseMailer < Devise::Mailer
def invitation_instructions(record, token, opts = {})
@workspace = opts[:workspace]
@role = opts[:role]
+ @is_verified = opts[:is_verified] || false
@token = token
super
end
diff --git a/server/app/views/devise/mailer/invitation_instructions.html.erb b/server/app/views/devise/mailer/invitation_instructions.html.erb
index 06a8630a..16b7ebf3 100644
--- a/server/app/views/devise/mailer/invitation_instructions.html.erb
+++ b/server/app/views/devise/mailer/invitation_instructions.html.erb
@@ -60,7 +60,7 @@
<%= "#{@resource.invited_by.name} has invited you to use AI Squared with them, in a workspace called #{@workspace.name}." %>
<% query_params = { invited: true, invited_user:@resource.email, invitation_token: @token, workspace_id: @workspace.id, workspace_name: @workspace.name, invited_by: @resource.invited_by.name } %>
- <% custom_url = "#{ENV['UI_HOST']}/sign-up?#{query_params.to_query}" %>
+ <% custom_url = @is_verified ? "#{ENV['UI_HOST']}/sign-in" : "#{ENV['UI_HOST']}/sign-up?#{query_params.to_query}" %>
- <% if @resource.invitation_due_at %>
+ <% if !@is_verified && @resource.invitation_due_at %>
<%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %>
<% end %>