From 0df8c70520366009cea4f16c84042e3a5303b6b5 Mon Sep 17 00:00:00 2001 From: Mahesh Makani Date: Thu, 18 Jan 2024 15:05:46 +0000 Subject: [PATCH] feat(consents): show "Subscription Confirmation" page when coming from consent confirmation email --- .../ete/consent_token/consent_token.2.cy.ts | 10 +++------- src/server/routes/consentToken.ts | 5 ++--- src/server/routes/subscriptions.ts | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cypress/integration/ete/consent_token/consent_token.2.cy.ts b/cypress/integration/ete/consent_token/consent_token.2.cy.ts index 54eece99a..3c1c41132 100644 --- a/cypress/integration/ete/consent_token/consent_token.2.cy.ts +++ b/cypress/integration/ete/consent_token/consent_token.2.cy.ts @@ -1,5 +1,5 @@ describe('Consent token flow', () => { - it('redirects to the success route when supplied a valid token by a logged in user', () => { + it('shows the success page when supplied a valid token by a logged in user', () => { cy.createTestUser({ isUserEmailValidated: true, }).then(({ emailAddress, cookies }) => { @@ -24,12 +24,8 @@ describe('Consent token flow', () => { cy.visit(`/consent-token/${token}/accept`, { failOnStatusCode: false, }); - // /consents/thank-you isn't hosted by Gateway so all we need to check - // is that the cy.visit() redirected successfully, so intercept the request - // and return a 200 - cy.intercept('GET', '/consents/thank-you', (req) => { - req.reply(200); - }); + cy.contains('Subscribe Confirmation'); + cy.url().should('include', '/subscribe/success'); }); }); }); diff --git a/src/server/routes/consentToken.ts b/src/server/routes/consentToken.ts index 73bf24481..4907b8859 100644 --- a/src/server/routes/consentToken.ts +++ b/src/server/routes/consentToken.ts @@ -10,6 +10,7 @@ import { import { mergeRequestState } from '@/server/lib/requestState'; import { logger } from '@/server/lib/serverSideLogger'; import { trackMetric } from '@/server/lib/trackMetric'; +import { buildUrl } from '@/shared/lib/routeUtils'; // This route is of this specific form because it's a direct copy of the legacy // route in identity-frontend, and emails sent by IDAPI contain this URL. @@ -25,9 +26,7 @@ router.get( trackMetric('ConsentToken::Success'); - // Redirect to /consents/thank-you (a page managed by Frontend). This is - // to retain the legacy behaviour of the route from identity-frontend. - return res.redirect(303, '/consents/thank-you?useIdapi=true'); + return res.redirect(303, buildUrl('/subscribe/success')); } catch (error) { logger.error(`${req.method} ${req.originalUrl} Error`, error, { request_id: res.locals.requestId, diff --git a/src/server/routes/subscriptions.ts b/src/server/routes/subscriptions.ts index df1008dcf..870dbc4c5 100644 --- a/src/server/routes/subscriptions.ts +++ b/src/server/routes/subscriptions.ts @@ -85,4 +85,21 @@ const handler = (action: SubscriptionAction) => router.get('/unsubscribe/:emailType/:data/:token', handler('unsubscribe')); router.get('/subscribe/:emailType/:data/:token', handler('subscribe')); +router.get( + '/subscribe/success', + (_: Request, res: ResponseWithRequestState) => { + // show the subscribe confirmation page + const html = renderer(`/subscribe/success`, { + requestState: mergeRequestState(res.locals, { + pageData: { + accountManagementUrl, + }, + }), + pageTitle: `Subscribe Confirmation`, + }); + + return res.type('html').send(html); + }, +); + export default router.router;