The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
test(e2e): cookie-authenticate direct backend calls, and clear the token pair on switch (#24982)
Félix Malfait39535a8248d6
diff --git a/packages/twenty-e2e-testing/lib/requests/backend.ts b/packages/twenty-e2e-testing/lib/requests/backend.tsindex 73d57b1a52a..f1094013ff6 100644--- a/packages/twenty-e2e-testing/lib/requests/backend.ts+++ b/packages/twenty-e2e-testing/lib/requests/backend.ts@@ -2,3 +2,8 @@ export const backendGraphQLUrl = new URL('/graphql',process.env.BACKEND_BASE_URL,).toString();++// Mirrors the baseURL default in playwright.config.ts.+export const frontendOrigin = new URL(+ process.env.FRONTEND_BASE_URL || 'http://localhost:3001',+).origin;diff --git a/packages/twenty-e2e-testing/lib/requests/create-workflow.ts b/packages/twenty-e2e-testing/lib/requests/create-workflow.tsindex be3eb0e29b3..17ab61ad35b 100644--- a/packages/twenty-e2e-testing/lib/requests/create-workflow.ts+++ b/packages/twenty-e2e-testing/lib/requests/create-workflow.ts@@ -1,6 +1,5 @@import { type Page } from '@playwright/test';-import { getAccessAuthToken } from '../utils/getAccessAuthToken';-import { backendGraphQLUrl } from './backend';+import { postBackendGraphQL } from './post-backend-graphql';export const createWorkflow = async ({page,@@ -11,12 +10,8 @@ export const createWorkflow = async ({workflowId: string;workflowName: string;}) => {- const { authToken } = await getAccessAuthToken(page);-- return page.request.post(backendGraphQLUrl, {- headers: {- Authorization: `Bearer ${authToken}`,- },+ return postBackendGraphQL({+ page,data: {operationName: 'CreateOneWorkflow',query:diff --git a/packages/twenty-e2e-testing/lib/requests/delete-workflow.ts b/packages/twenty-e2e-testing/lib/requests/delete-workflow.tsindex a98bc0c2ec9..a374bee8a4e 100644--- a/packages/twenty-e2e-testing/lib/requests/delete-workflow.ts+++ b/packages/twenty-e2e-testing/lib/requests/delete-workflow.ts@@ -1,6 +1,5 @@import { type Page } from '@playwright/test';-import { getAccessAuthToken } from '../utils/getAccessAuthToken';-import { backendGraphQLUrl } from './backend';+import { postBackendGraphQL } from './post-backend-graphql';export const deleteWorkflow = async ({page,@@ -9,12 +8,8 @@ export const deleteWorkflow = async ({page: Page;workflowId: string;}) => {- const { authToken } = await getAccessAuthToken(page);-- return page.request.post(backendGraphQLUrl, {- headers: {- Authorization: `Bearer ${authToken}`,- },+ return postBackendGraphQL({+ page,data: {operationName: 'DeleteOneWorkflow',variables: { idToDelete: workflowId },diff --git a/packages/twenty-e2e-testing/lib/requests/destroy-workflow.ts b/packages/twenty-e2e-testing/lib/requests/destroy-workflow.tsindex 1ce73d22c52..fbe1a062f70 100644--- a/packages/twenty-e2e-testing/lib/requests/destroy-workflow.ts+++ b/packages/twenty-e2e-testing/lib/requests/destroy-workflow.ts@@ -1,6 +1,5 @@import { type Page } from '@playwright/test';-import { getAccessAuthToken } from '../utils/getAccessAuthToken';-import { backendGraphQLUrl } from './backend';+import { postBackendGraphQL } from './post-backend-graphql';export const destroyWorkflow = async ({page,@@ -9,12 +8,8 @@ export const destroyWorkflow = async ({page: Page;workflowId: string;}) => {- const { authToken } = await getAccessAuthToken(page);-- return page.request.post(backendGraphQLUrl, {- headers: {- Authorization: `Bearer ${authToken}`,- },+ return postBackendGraphQL({+ page,data: {operationName: 'DestroyOneWorkflow',variables: { idToDestroy: workflowId },diff --git a/packages/twenty-e2e-testing/lib/requests/post-backend-graphql.ts b/packages/twenty-e2e-testing/lib/requests/post-backend-graphql.tsnew file mode 100644index 00000000000..849298f81f6--- /dev/null+++ b/packages/twenty-e2e-testing/lib/requests/post-backend-graphql.ts@@ -0,0 +1,20 @@+import { type APIResponse, type Page } from '@playwright/test';+import { backendGraphQLUrl, frontendOrigin } from './backend';++// Authenticates by session cookie: page.request shares the browser context's+// cookie jar, which is the only place an httpOnly session cookie exists.+// CookieSessionCsrfMiddleware fails closed on a missing Origin for a+// cookie-authenticated write, and page.request sends none on its own.+export const postBackendGraphQL = ({+ page,+ data,+}: {+ page: Page;+ data: Record<string, unknown>;+}): Promise<APIResponse> =>+ page.request.post(backendGraphQLUrl, {+ headers: {+ Origin: frontendOrigin,+ },+ data,+ });diff --git a/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.ts b/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.tsdeleted file mode 100644index c6ad3843a42..00000000000--- a/packages/twenty-e2e-testing/lib/utils/getAccessAuthToken.ts+++ /dev/null@@ -1,22 +0,0 @@-import { type Page } from '@playwright/test';--// Mirrors TOKEN_PAIR_LOCAL_STORAGE_KEY from twenty-front-// (packages/twenty-front/src/modules/auth/states/tokenPairState.ts).-// Since #21507 the frontend stores the auth token pair in localStorage-// instead of a cookie.-const TOKEN_PAIR_LOCAL_STORAGE_KEY = 'tokenPairState';--export const getAccessAuthToken = async (page: Page) => {- const storageState = await page.context().storageState();- const tokenPairItem = storageState.origins- .flatMap((origin) => origin.localStorage)- .find((item) => item.name === TOKEN_PAIR_LOCAL_STORAGE_KEY);-- if (tokenPairItem === undefined) {- throw new Error('No auth token pair found in local storage');- }-- const { accessOrWorkspaceAgnosticToken } = JSON.parse(tokenPairItem.value);-- return { authToken: accessOrWorkspaceAgnosticToken.token };-};diff --git a/packages/twenty-e2e-testing/tests/create-record.spec.ts b/packages/twenty-e2e-testing/tests/create-record.spec.tsindex 8a88c4053dd..562771aada8 100644--- a/packages/twenty-e2e-testing/tests/create-record.spec.ts+++ b/packages/twenty-e2e-testing/tests/create-record.spec.ts@@ -1,6 +1,5 @@import { expect, test } from '../lib/fixtures/screenshot';-import { backendGraphQLUrl } from '../lib/requests/backend';-import { getAccessAuthToken } from '../lib/utils/getAccessAuthToken';+import { postBackendGraphQL } from '../lib/requests/post-backend-graphql';const query = `query FindOnePerson($objectRecordId: UUID!) {person(@@ -119,11 +118,8 @@ test('Create and update record', async ({ page }) => {const newPersonId = page.url().match(/\/object\/person\/([a-f0-9-]+)/)?.[1];// Check data was saved- const { authToken } = await getAccessAuthToken(page);- const findOnePersonResponse = await page.request.post(backendGraphQLUrl, {- headers: {- Authorization: `Bearer ${authToken}`,- },+ const findOnePersonResponse = await postBackendGraphQL({+ page,data: {operationName: 'FindOnePerson',query,diff --git a/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.ts b/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.tsindex f27c6a1fb36..63bf9ab7296 100644--- a/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.ts+++ b/packages/twenty-front/src/modules/apollo/services/__tests__/apollo.factory.test.ts@@ -55,13 +55,6 @@ const UNAUTHENTICATED_RESPONSE = JSON.stringify({errors: [{ extensions: { code: 'UNAUTHENTICATED' } }],});-const FORBIDDEN_RESOURCE_RESPONSE = JSON.stringify({- data: { trackAnalytics: null },- errors: [- { message: 'Forbidden resource', extensions: { code: 'FORBIDDEN' } },- ],-});-const PERMISSION_DENIED_RESPONSE = JSON.stringify({data: { trackAnalytics: null },errors: [@@ -399,7 +392,7 @@ describe('ApolloFactory', () => {expect(renewToken).not.toHaveBeenCalled();expect(mockOnUnauthenticatedError).toHaveBeenCalledTimes(1);});- describe('cookie auth fallback during a mixed-version rollout', () => {+ describe('cookie auth', () => {const setCookieAuthActive = () =>jotaiStore.set(isCookieAuthActiveState.atom, true);@@ -413,6 +406,9 @@ describe('ApolloFactory', () => {([key]) => key.toLowerCase() === name.toLowerCase(),)?.[1];+ // A pair still exists between sign-in and the boot effect's switch, and+ // across the impersonation exchange. Sending it would take precedence over+ // the session cookie server-side and bypass the CSRF origin check.it('should not attach the Bearer header while cookie auth is active', async () => {setCookieAuthActive();fetchMock.mockResponse(() =>@@ -431,94 +427,6 @@ describe('ApolloFactory', () => {expect(readHeader(headers, 'X-App-Version')).toBe('1.0.0');});- it('should fall back to the token pair instead of signing out when a server ignores the session cookie', async () => {- setCookieAuthActive();- fetchMock- .mockResponseOnce(UNAUTHENTICATED_RESPONSE)- .mockResponseOnce(JSON.stringify({ data: { trackAnalytics: null } }));-- await makeRequest();-- expect(mockOnUnauthenticatedError).not.toHaveBeenCalled();- expect(jotaiStore.get(isCookieAuthActiveState.atom)).toBe(false);-- const retryHeaders = fetchMock.mock.calls[1]?.[1]?.headers as Record<- string,- string- >;-- expect(readHeader(retryHeaders, 'authorization')).toBe(- `Bearer ${RENEWED_TOKEN_PAIR.accessOrWorkspaceAgnosticToken.token}`,- );- });-- it('should only attempt the cookie fallback once, then go through renewal', async () => {- setCookieAuthActive();- fetchMock.mockResponse(UNAUTHENTICATED_RESPONSE);-- try {- await makeRequest();- } catch {}-- expect(jotaiStore.get(isCookieAuthActiveState.atom)).toBe(false);- expect(renewToken).toHaveBeenCalled();- });-- // A server that never read the session cookie -- an old pod mid-rollout, or- // a cookie the browser no longer holds -- leaves the request with no- // credential at all, which the guards refuse as FORBIDDEN.- it('should renew the retained token pair and replay when a credential-less request is refused', async () => {- setCookieAuthActive();- fetchMock- .mockResponseOnce(FORBIDDEN_RESOURCE_RESPONSE)- .mockResponseOnce(JSON.stringify({ data: { trackAnalytics: null } }));-- await makeRequest();-- expect(jotaiStore.get(isCookieAuthActiveState.atom)).toBe(false);- expect(renewToken).toHaveBeenCalledTimes(1);- expect(mockOnTokenPairChange).toHaveBeenCalledWith(RENEWED_TOKEN_PAIR);- expect(mockOnUnauthenticatedError).not.toHaveBeenCalled();-- const retryHeaders = fetchMock.mock.calls[1]?.[1]?.headers as Record<- string,- string- >;-- expect(readHeader(retryHeaders, 'authorization')).toBe(- `Bearer ${RENEWED_TOKEN_PAIR.accessOrWorkspaceAgnosticToken.token}`,- );- });-- it('should attempt the credential-less fallback only once per operation', async () => {- setCookieAuthActive();- fetchMock.mockResponse(FORBIDDEN_RESOURCE_RESPONSE);-- await expect(makeRequest()).rejects.toBeInstanceOf(CombinedGraphQLErrors);-- expect(fetchMock).toHaveBeenCalledTimes(2);- expect(renewToken).toHaveBeenCalledTimes(1);- expect(mockOnUnauthenticatedError).not.toHaveBeenCalled();- });-- it('should sign out when the refresh token is rejected during the fallback', async () => {- setCookieAuthActive();- jest.mocked(renewToken).mockRejectedValue(- new CombinedGraphQLErrors(- {- data: null,- errors: [{ message: 'x', extensions: { code: 'UNAUTHENTICATED' } }],- },- [{ message: 'x', extensions: { code: 'UNAUTHENTICATED' } }],- ),- );- fetchMock.mockResponse(FORBIDDEN_RESOURCE_RESPONSE);-- await expect(makeRequest()).rejects.toBeInstanceOf(CombinedGraphQLErrors);-- expect(mockOnUnauthenticatedError).toHaveBeenCalled();- });-it('should leave a permission denial alone', async () => {setCookieAuthActive();fetchMock.mockResponse(PERMISSION_DENIED_RESPONSE);@@ -530,24 +438,33 @@ describe('ApolloFactory', () => {expect(mockOnUnauthenticatedError).not.toHaveBeenCalled();});- it('should not fall back on a credential-less refusal while authenticating by token', async () => {- fetchMock.mockResponse(FORBIDDEN_RESOURCE_RESPONSE);+ // CookieSessionBootEffect can switch to cookie auth while a renewal is in+ // flight. Publishing that renewal would put the refresh token back for+ // good, since the boot effect only probes while cookie auth is inactive.+ it('should not restore the token pair when it is cleared mid-renewal', async () => {+ jest.mocked(renewToken).mockImplementation(async () => {+ storedTokenPair = undefined;+ setCookieAuthActive();++ return RENEWED_TOKEN_PAIR;+ });+ fetchMock.mockResponse(UNAUTHENTICATED_RESPONSE);await expect(makeRequest()).rejects.toBeInstanceOf(CombinedGraphQLErrors);- expect(fetchMock).toHaveBeenCalledTimes(1);- expect(mockOnUnauthenticatedError).not.toHaveBeenCalled();+ expect(renewToken).toHaveBeenCalled();+ expect(mockOnTokenPairChange).not.toHaveBeenCalled();});- it('should not fall back on a credential-less refusal for the cookie session probe', async () => {+ it('should sign out on an unauthenticated response, with no pair to fall back to', async () => {setCookieAuthActive();- fetchMock.mockResponse(FORBIDDEN_RESOURCE_RESPONSE);+ storedTokenPair = undefined;+ fetchMock.mockResponse(UNAUTHENTICATED_RESPONSE);- await expect(- makeRequestWithContext({ skipAuthToken: true }),- ).rejects.toBeInstanceOf(CombinedGraphQLErrors);+ await expect(makeRequest()).rejects.toBeInstanceOf(CombinedGraphQLErrors);- expect(fetchMock).toHaveBeenCalledTimes(1);+ expect(renewToken).not.toHaveBeenCalled();+ expect(mockOnUnauthenticatedError).toHaveBeenCalledTimes(1);expect(jotaiStore.get(isCookieAuthActiveState.atom)).toBe(true);});});diff --git a/packages/twenty-front/src/modules/apollo/services/apollo.factory.ts b/packages/twenty-front/src/modules/apollo/services/apollo.factory.tsindex e1c2d398acd..d7e6a94fe20 100644--- a/packages/twenty-front/src/modules/apollo/services/apollo.factory.ts+++ b/packages/twenty-front/src/modules/apollo/services/apollo.factory.ts@@ -22,8 +22,6 @@ import { REST_API_BASE_URL } from '@/apollo/constant/rest-api-base-url';import { type ApolloManager } from '@/apollo/types/apolloManager.interface';import { getIsCookieAuthActive } from '@/apollo/utils/getIsCookieAuthActive';import { getTokenPair } from '@/apollo/utils/getTokenPair';-import { setIsCookieAuthActive } from '@/apollo/utils/setIsCookieAuthActive';-import { isMissingCredentialGraphQLError } from '@/apollo/utils/isMissingCredentialGraphQLError';import { isUnauthenticatedGraphQLError } from '@/apollo/utils/isUnauthenticatedGraphQLError';import { loggerLink } from '@/apollo/utils/loggerLink';import { StreamingRestLink } from '@/apollo/utils/streamingRestLink';@@ -136,10 +134,11 @@ export class ApolloFactory implements ApolloManager {const locale = this.currentWorkspaceMember?.locale ?? i18n.locale;- // The token pair is kept as a dormant fallback once cookie auth is- // active, but must not be sent: Bearer takes precedence over the- // session cookie server-side, so attaching it would keep the cookie- // unused and bypass the CSRF origin check.+ // A pair can still be present while cookie auth is active: sign-in and+ // the impersonation exchange both store one before the cookie takes+ // over. It must not be sent. Bearer takes precedence over the session+ // cookie server-side, so attaching it would keep the cookie unused and+ // bypass the CSRF origin check.if (isUndefinedOrNull(tokenPair) ||skipAuthToken === true ||@@ -194,6 +193,7 @@ export class ApolloFactory implements ApolloManager {const attemptTokenRenewal = async (): Promise<void> => {const graphqlUri = `${REACT_APP_SERVER_BASE_URL}/metadata`;+ const refreshTokenSnapshot = getTokenPair()?.refreshToken?.token;const tokens = await retryWithBackoff(() => renewToken(graphqlUri, getTokenPair()),@@ -205,19 +205,19 @@ export class ApolloFactory implements ApolloManager {},);- if (isDefined(tokens)) {+ // Same snapshot guard as ensureTokenRenewed. CookieSessionBootEffect+ // can clear the pair while this is in flight, and publishing anyway+ // would put a fresh refresh token back in localStorage for good: the+ // boot effect only probes while cookie auth is inactive, so it never+ // clears it again.+ if (+ isDefined(tokens) &&+ getTokenPair()?.refreshToken?.token === refreshTokenSnapshot+ ) {onTokenPairChange?.(tokens);}};- const canFallBackFromCookieAuth = (- operation: ApolloLink.Operation,- ): boolean =>- getIsCookieAuthActive() &&- operation.getContext().skipAuthToken !== true &&- operation.getContext().hasAttemptedCookieAuthFallback !== true &&- isDefined(getTokenPair()?.refreshToken?.token);-const handleTokenRenewal = (operation: ApolloLink.Operation,forward: ApolloLink.ForwardFunction,@@ -229,27 +229,6 @@ export class ApolloFactory implements ApolloManager {return throwError(() => error);}- // A server that still has cookie sessions disabled ignores the session- // cookie, so a cookie-only client reads as unauthenticated there. That- // happens on every request routed to a not-yet-rolled pod, and after a- // rollback. Fall back to the retained token pair instead of signing the- // user out. Attempted once per operation so a genuinely expired token- // still reaches the renewal path below.- if (canFallBackFromCookieAuth(operation)) {- setIsCookieAuthActive(false);- operation.setContext({ hasAttemptedCookieAuthFallback: true });- // Deactivation is sticky for the rest of the mount by design. Both- // credentials stay valid, so re-probing after every fallback would- // thrash between them for the whole rollout: the probe succeeds on a- // rolled pod, the next request lands on an old one and falls back- // again. CookieSessionBootEffect re-probes on the next mount, which- // restores cookie auth once the fleet is uniform.- // Deliberately falls through to the renewal below rather than- // replaying immediately: the retained access token is likely to have- // expired while the client was authenticating by cookie, so the- // replay needs a fresh one to succeed on the first try.- }-if (!getTokenPair()?.refreshToken?.token) {onUnauthenticatedError?.();@@ -357,21 +336,6 @@ export class ApolloFactory implements ApolloManager {return handleTokenRenewal(operation, forward, error);}- // Goes through handleTokenRenewal rather than replaying directly:- // ErrorLink subscribes a replay straight to the original observer,- // so an UNAUTHENTICATED on it never re-enters this handler.- if (- isMissingCredentialGraphQLError(graphQLError) &&- canFallBackFromCookieAuth(operation)- ) {- // oxlint-disable-next-line no-console- console.log(- 'Session cookie was not accepted, falling back to the token pair',- );-- return handleTokenRenewal(operation, forward, error);- }-switch (graphQLError?.extensions?.code) {case 'APP_VERSION_MISMATCH': {onAppVersionMismatch?.(diff --git a/packages/twenty-front/src/modules/apollo/utils/isMissingCredentialGraphQLError.ts b/packages/twenty-front/src/modules/apollo/utils/isMissingCredentialGraphQLError.tsdeleted file mode 100644index 7933e6a4ba5..00000000000--- a/packages/twenty-front/src/modules/apollo/utils/isMissingCredentialGraphQLError.ts+++ /dev/null@@ -1,10 +0,0 @@-import { type GraphQLFormattedError } from 'graphql';--// Matched on the message, not the code alone: a permission denial is also-// FORBIDDEN but carries the message its exception set, whereas "Forbidden-// resource" is Nest's default for a guard rejecting an unhydrated request.-export const isMissingCredentialGraphQLError = (- graphQLError: GraphQLFormattedError,-): boolean =>- graphQLError.extensions?.code === 'FORBIDDEN' &&- graphQLError.message === 'Forbidden resource';diff --git a/packages/twenty-front/src/modules/apollo/utils/setIsCookieAuthActive.ts b/packages/twenty-front/src/modules/apollo/utils/setIsCookieAuthActive.tsdeleted file mode 100644index 1688d350ff4..00000000000--- a/packages/twenty-front/src/modules/apollo/utils/setIsCookieAuthActive.ts+++ /dev/null@@ -1,14 +0,0 @@-import { isCookieAuthActiveState } from '@/auth/states/isCookieAuthActiveState';-import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';--// Goes through the atom so the persisted key keeps a single writer, and so-// React subscribers follow without the caller mirroring this into component-// state. Guarded because it runs inside unauthenticated error handling, where-// blocked storage would otherwise throw out of the error path.-export const setIsCookieAuthActive = (isActive: boolean): void => {- try {- jotaiStore.set(isCookieAuthActiveState.atom, isActive);- } catch {- // noop- }-};diff --git a/packages/twenty-front/src/modules/auth/effect-components/CookieSessionBootEffect.tsx b/packages/twenty-front/src/modules/auth/effect-components/CookieSessionBootEffect.tsxindex e55facfd9b2..115466ccb9f 100644--- a/packages/twenty-front/src/modules/auth/effect-components/CookieSessionBootEffect.tsx+++ b/packages/twenty-front/src/modules/auth/effect-components/CookieSessionBootEffect.tsx@@ -21,10 +21,10 @@ type CookieSessionProbeResult =| 'unauthenticated'| 'unreachable';-// A request with no credential at all is refused as FORBIDDEN, while an-// invalid one is UNAUTHENTICATED, and guards that throw before the code is-// attached surface a bare "Unauthorized". The probe deliberately sends no-// credential, so it has to recognise all three or the migration never starts.+// The probe deliberately sends no credential, so it has to recognise every+// shape that refusal takes. A credential-less request is UNAUTHENTICATED on a+// current server but FORBIDDEN on one predating the guard change, and guards+// that throw before the code is attached surface a bare "Unauthorized".const AUTH_REFUSAL_CODES = new Set(['UNAUTHENTICATED', 'FORBIDDEN']);const isAuthRefusal = (error: unknown): boolean =>@@ -45,7 +45,7 @@ export const CookieSessionBootEffect = () => {const [isCookieAuthActive, setIsCookieAuthActive] = useAtomState(isCookieAuthActiveState,);- const tokenPair = useAtomStateValue(tokenPairState);+ const [tokenPair, setTokenPair] = useAtomState(tokenPairState);// oxlint-disable-next-line twenty/no-state-userefconst hasProbeRunRef = useRef(false);@@ -66,15 +66,9 @@ export const CookieSessionBootEffect = () => {}};- // The token pair is deliberately retained rather than cleared. A server- // that predates cookie sessions ignores the session cookie, so a- // cookie-only client is unauthenticated against it — which is every request- // routed to a not-yet-rolled pod during a deploy, and every request after a- // rollback. Keeping the pair lets those fall back instead of signing the- // user out. It stops being sent while cookie auth is active, so the cookie- // is still the credential in use.const switchToCookieAuth = () => {setIsCookieAuthActive(true);+ setTokenPair(null);};const attemptCookieSessionBoot = async (): Promise<boolean> => {@@ -140,6 +134,7 @@ export const CookieSessionBootEffect = () => {isCookieAuthActive,isLoadedOnce,setIsCookieAuthActive,+ setTokenPair,store,tokenPair,]);diff --git a/packages/twenty-front/src/modules/auth/effect-components/__tests__/CookieSessionBootEffect.test.tsx b/packages/twenty-front/src/modules/auth/effect-components/__tests__/CookieSessionBootEffect.test.tsxindex 7a562328ef5..7150d731c65 100644--- a/packages/twenty-front/src/modules/auth/effect-components/__tests__/CookieSessionBootEffect.test.tsx+++ b/packages/twenty-front/src/modules/auth/effect-components/__tests__/CookieSessionBootEffect.test.tsx@@ -87,9 +87,7 @@ describe('CookieSessionBootEffect', () => {expect(store.get(isCookieAuthActiveState.atom)).toBe(true);});- // Retained as a fallback for servers that predate cookie sessions, which- // would otherwise sign the user out mid-rollout.- expect(store.get(tokenPairState.atom)).not.toBeNull();+ expect(store.get(tokenPairState.atom)).toBeNull();});it('should stay retryable when the probe fails for an unrelated reason', async () => {@@ -138,6 +136,7 @@ describe('CookieSessionBootEffect', () => {expect(store.get(isCookieAuthActiveState.atom)).toBe(true);});+ expect(store.get(tokenPairState.atom)).toBeNull();expect(mockEnsureTokenRenewed).not.toHaveBeenCalled();});});diff --git a/packages/twenty-front/src/modules/sse-db-event/components/SSEClientEffect.tsx b/packages/twenty-front/src/modules/sse-db-event/components/SSEClientEffect.tsxindex ba13b3a744a..091043d3658 100644--- a/packages/twenty-front/src/modules/sse-db-event/components/SSEClientEffect.tsx+++ b/packages/twenty-front/src/modules/sse-db-event/components/SSEClientEffect.tsx@@ -63,10 +63,10 @@ export const SSEClientEffect = () => {url: `${REACT_APP_SERVER_BASE_URL}/metadata`,credentials: 'include',headers: (): Record<string, string> => {- // Same rule as the Apollo auth link: the retained token pair is a- // dormant fallback once cookie auth is active and must not be sent.- // The server prefers Bearer over the session cookie, so attaching a- // token nothing refreshes any more authenticates the stream with a+ // Same rule as the Apollo auth link: a pair can still be present+ // while cookie auth is active, and must not be sent. The server+ // prefers Bearer over the session cookie, so attaching a token+ // nothing refreshes any more authenticates the stream with a// credential that expires and never recovers.if (store.get(isCookieAuthActiveState.atom)) {return {};