mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27:52 +00:00
fix: Adds domain option to user cookies set by SDK [CW-352] (#7070)
* fix: Adds domain option to user cookies set by SDK * Adds domain to init event from chatwootSettings variable * Testing multiple domains on heroku * Updates with sdk from staging * Removes sdk init code * Testing why cookie is not getting set * Cleans up testing code * Refactors code to fix codeclimate issues * Update app/javascript/sdk/cookieHelpers.js Co-authored-by: Shivam Mishra <scm.mymail@gmail.com> * Adds test cases for setCookieWithDomain --------- Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
This commit is contained in:
committed by
GitHub
parent
d25e7fd54e
commit
1017903ee1
@@ -29,7 +29,7 @@ import {
|
||||
CHATWOOT_READY,
|
||||
} from '../widget/constants/sdkEvents';
|
||||
import { SET_USER_ERROR } from '../widget/constants/errorTypes';
|
||||
import { getUserCookieName } from './cookieHelpers';
|
||||
import { getUserCookieName, setCookieWithDomain } from './cookieHelpers';
|
||||
import {
|
||||
getAlertAudio,
|
||||
initOnEvents,
|
||||
@@ -38,17 +38,16 @@ import { isFlatWidgetStyle } from './settingsHelper';
|
||||
import { popoutChatWindow } from '../widget/helpers/popoutHelper';
|
||||
import addHours from 'date-fns/addHours';
|
||||
|
||||
const updateAuthCookie = cookieContent =>
|
||||
Cookies.set('cw_conversation', cookieContent, {
|
||||
expires: 365,
|
||||
sameSite: 'Lax',
|
||||
const updateAuthCookie = (cookieContent, baseDomain = '') =>
|
||||
setCookieWithDomain('cw_conversation', cookieContent, {
|
||||
baseDomain,
|
||||
});
|
||||
|
||||
const updateCampaignReadStatus = () => {
|
||||
const updateCampaignReadStatus = baseDomain => {
|
||||
const expireBy = addHours(new Date(), 1);
|
||||
Cookies.set('cw_snooze_campaigns_till', Number(expireBy), {
|
||||
setCookieWithDomain('cw_snooze_campaigns_till', Number(expireBy), {
|
||||
expires: expireBy,
|
||||
sameSite: 'Lax',
|
||||
baseDomain,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -154,7 +153,7 @@ export const IFrameHelper = {
|
||||
|
||||
events: {
|
||||
loaded: message => {
|
||||
updateAuthCookie(message.config.authToken);
|
||||
updateAuthCookie(message.config.authToken, window.$chatwoot.baseDomain);
|
||||
window.$chatwoot.hasLoaded = true;
|
||||
const campaignsSnoozedTill = Cookies.get('cw_snooze_campaigns_till');
|
||||
IFrameHelper.sendMessage('config-set', {
|
||||
@@ -200,11 +199,11 @@ export const IFrameHelper = {
|
||||
},
|
||||
|
||||
setAuthCookie({ data: { widgetAuthToken } }) {
|
||||
updateAuthCookie(widgetAuthToken);
|
||||
updateAuthCookie(widgetAuthToken, window.$chatwoot.baseDomain);
|
||||
},
|
||||
|
||||
setCampaignReadOn() {
|
||||
updateCampaignReadStatus();
|
||||
updateCampaignReadStatus(window.$chatwoot.baseDomain);
|
||||
},
|
||||
|
||||
toggleBubble: state => {
|
||||
|
||||
Reference in New Issue
Block a user