From 9bc0be17168a220a6e80c47c59fbd1bcbd80750c Mon Sep 17 00:00:00 2001 From: Maurice Date: Mon, 30 Nov 2026 15:20:05 +0100 Subject: [PATCH] fix(journey): open the follower mail links under the public path prefix The confirm and unsubscribe pages lived at /journey-follow/, which the client does not treat as a public path, so a reader without an account could be sent into the proxy re-auth flow. They now sit under /public/journey-follow/ beside the shared journey itself. --- client/src/pages/journeyFollow/useJourneyFollow.ts | 4 ++-- server/src/nest/journey/journey-subscription-mail.ts | 4 ++-- server/tests/e2e/journey-social.e2e.test.ts | 4 ++-- server/tests/unit/nest/journey/journey-social.helpers.test.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/pages/journeyFollow/useJourneyFollow.ts b/client/src/pages/journeyFollow/useJourneyFollow.ts index b8b2ea0de..cc8a25302 100644 --- a/client/src/pages/journeyFollow/useJourneyFollow.ts +++ b/client/src/pages/journeyFollow/useJourneyFollow.ts @@ -22,8 +22,8 @@ export function followFailureOf(err: unknown): JourneyFollowState { } /** - * The page a follower's mail link opens (`/journey-follow/confirm?token=` or - * `/journey-follow/unsubscribe?token=`): it posts the token once and says + * The page a follower's mail link opens (`/public/journey-follow/confirm?token=` or + * `/public/journey-follow/unsubscribe?token=`): it posts the token once and says * what came of it. The page does the write, never the link itself, so a mail * scanner that fetches the link changes nothing. */ diff --git a/server/src/nest/journey/journey-subscription-mail.ts b/server/src/nest/journey/journey-subscription-mail.ts index d6aea26a7..b2d88b642 100644 --- a/server/src/nest/journey/journey-subscription-mail.ts +++ b/server/src/nest/journey/journey-subscription-mail.ts @@ -30,12 +30,12 @@ function withJourney(text: string, journey: string): string { /** The page that confirms an address. */ export function confirmUrl(confirmToken: string): string { - return `${getAppUrl()}/journey-follow/confirm?token=${encodeURIComponent(confirmToken)}`; + return `${getAppUrl()}/public/journey-follow/confirm?token=${encodeURIComponent(confirmToken)}`; } /** The page that stops the mails to an address. */ export function unsubscribeUrl(unsubscribeToken: string): string { - return `${getAppUrl()}/journey-follow/unsubscribe?token=${encodeURIComponent(unsubscribeToken)}`; + return `${getAppUrl()}/public/journey-follow/unsubscribe?token=${encodeURIComponent(unsubscribeToken)}`; } /** The shared journey itself. */ diff --git a/server/tests/e2e/journey-social.e2e.test.ts b/server/tests/e2e/journey-social.e2e.test.ts index a72ee418e..617760598 100644 --- a/server/tests/e2e/journey-social.e2e.test.ts +++ b/server/tests/e2e/journey-social.e2e.test.ts @@ -314,8 +314,8 @@ describe('following a link by email', () => { expect(send).toHaveBeenCalledTimes(1); const [to, mail] = must(send.mock.calls[0]); expect(to).toBe('ana@example.com'); - expect(mail.cta.href).toContain(`/journey-follow/confirm?token=${row.confirm_token}`); - expect(mail.footer.href).toContain(`/journey-follow/unsubscribe?token=${row.unsubscribe_token}`); + expect(mail.cta.href).toContain(`/public/journey-follow/confirm?token=${row.confirm_token}`); + expect(mail.footer.href).toContain(`/public/journey-follow/unsubscribe?token=${row.unsubscribe_token}`); expect(mail.subject).toContain('Azores'); // Asking again while it waits sends the same confirmation again, and adds nobody. diff --git a/server/tests/unit/nest/journey/journey-social.helpers.test.ts b/server/tests/unit/nest/journey/journey-social.helpers.test.ts index a7f52c50b..72017c1fd 100644 --- a/server/tests/unit/nest/journey/journey-social.helpers.test.ts +++ b/server/tests/unit/nest/journey/journey-social.helpers.test.ts @@ -91,8 +91,8 @@ describe('the mails of a follower', () => { const mail = confirmationMail('de', 'Azoren', { confirm: 'c-token', unsubscribe: 'u-token' }); expect(mail.subject).toBe('Bestätige dein Abo für "Azoren"'); expect(mail.body).toContain('"Azoren"'); - expect(mail.cta.href).toMatch(/\/journey-follow\/confirm\?token=c-token$/); - expect(mail.footer.href).toMatch(/\/journey-follow\/unsubscribe\?token=u-token$/); + expect(mail.cta.href).toMatch(/\/public\/journey-follow\/confirm\?token=c-token$/); + expect(mail.footer.href).toMatch(/\/public\/journey-follow\/unsubscribe\?token=u-token$/); expect(confirmationMail('xx', 'A', { confirm: 'c', unsubscribe: 'u' }).cta.label).toBe('Confirm subscription'); });