Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬
Ruby actioncablechat-widgetconversationcustomer-supportdashboarddesigndockerdocker-imageherokuintercomjavascriptlivechatopensourcerailsrubysassvuejswhatsappzendesk
chore: Stop setting session cookie on public pages (Fixes #2683) (#16350)
usamaimranabf371d2c080
diff --git a/app/views/layouts/_portal_head.html.erb b/app/views/layouts/_portal_head.html.erbindex e77139c789a..4f8ae1e6a9f 100644--- a/app/views/layouts/_portal_head.html.erb+++ b/app/views/layouts/_portal_head.html.erb@@ -12,7 +12,6 @@display: none;}</style>-<%= csrf_meta_tags %><% if content_for?(:head) %><%= yield(:head) %><% else %>diff --git a/app/views/survey/responses/show.html.erb b/app/views/survey/responses/show.html.erbindex 76ab9842ab9..c2dfa2903a8 100644--- a/app/views/survey/responses/show.html.erb+++ b/app/views/survey/responses/show.html.erb@@ -2,7 +2,6 @@<html><head><title><%= @global_config['INSTALLATION_NAME'] %></title>- <%= csrf_meta_tags %><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" /><script>window.globalConfig = <%= raw @global_config.to_json %>diff --git a/app/views/widgets/show.html.erb b/app/views/widgets/show.html.erbindex 4e03fb4ae15..d967dbc1cad 100644--- a/app/views/widgets/show.html.erb+++ b/app/views/widgets/show.html.erb@@ -2,7 +2,6 @@<html><head><title><%= @global_config['INSTALLATION_NAME'] %></title>- <%= csrf_meta_tags %><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" /><meta name="robots" content="noindex"><script>diff --git a/spec/controllers/public/api/v1/portals_controller_spec.rb b/spec/controllers/public/api/v1/portals_controller_spec.rbindex b6493c540eb..5488a4afd12 100644--- a/spec/controllers/public/api/v1/portals_controller_spec.rb+++ b/spec/controllers/public/api/v1/portals_controller_spec.rb@@ -25,6 +25,17 @@ RSpec.describe Public::Api::V1::PortalsController, type: :request doexpect(response).to have_http_status(:success)end+ it 'does not set the session cookie' do+ previous = ActionController::Base.allow_forgery_protection+ ActionController::Base.allow_forgery_protection = true++ get "/hc/#{portal.slug}/en"++ expect(response.headers['Set-Cookie'].to_s).not_to include('_chatwoot_session')+ ensure+ ActionController::Base.allow_forgery_protection = previous+ end+it 'Throws unauthorised error for unknown domain' doportal.update(custom_domain: 'www.something.com')diff --git a/spec/controllers/survey/responses_controller_spec.rb b/spec/controllers/survey/responses_controller_spec.rbnew file mode 100644index 00000000000..046b9fec5a6--- /dev/null+++ b/spec/controllers/survey/responses_controller_spec.rb@@ -0,0 +1,17 @@+require 'rails_helper'++describe '/survey/responses', type: :request do+ describe 'GET /survey/responses/:id' do+ it 'does not set the session cookie' do+ previous = ActionController::Base.allow_forgery_protection+ ActionController::Base.allow_forgery_protection = true++ get survey_response_url(id: SecureRandom.uuid)++ expect(response).to have_http_status(:ok)+ expect(response.headers['Set-Cookie'].to_s).not_to include('_chatwoot_session')+ ensure+ ActionController::Base.allow_forgery_protection = previous+ end+ end+enddiff --git a/spec/controllers/widgets_controller_spec.rb b/spec/controllers/widgets_controller_spec.rbindex ffb916c8abc..e44e6203c19 100644--- a/spec/controllers/widgets_controller_spec.rb+++ b/spec/controllers/widgets_controller_spec.rb@@ -37,6 +37,17 @@ describe '/widget', type: :request doexpect(response.body).to include('window.authToken')end+ it 'does not set the session cookie' do+ previous = ActionController::Base.allow_forgery_protection+ ActionController::Base.allow_forgery_protection = true++ get widget_url(website_token: web_widget.website_token)++ expect(response.headers['Set-Cookie'].to_s).not_to include('_chatwoot_session')+ ensure+ ActionController::Base.allow_forgery_protection = previous+ end+context 'when requested by a crawler' do%w[Googlebot bingbot].each do |crawler|it "returns no content without creating contacts for #{crawler}" do