Skip to content

Commit

Permalink
add message if user tries to go to newspaper auth without correct pro…
Browse files Browse the repository at this point in the history
…duct
  • Loading branch information
andrewHEguardian committed Oct 23, 2024
1 parent b516bc6 commit cabb12f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/components/mma/accountoverview/AccountOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { PaymentFailureAlertIfApplicable } from '../shared/PaymentFailureAlertIf
import { CancelledProductCard } from './CancelledProductCard';
import { EmptyAccountOverview } from './EmptyAccountOverview';
import { InAppPurchaseCard } from './InAppPurchaseCard';
import { MaybeNewspaperArchiveInfo } from './MaybeNewspaperArchiveInfo';
import { PersonalisedHeader } from './PersonalisedHeader';
import { ProductCard } from './ProductCard';
import { SingleContributionCard } from './SingleContributionCard';
Expand Down Expand Up @@ -196,6 +197,7 @@ const AccountOverviewPage = ({ isFromApp }: IsFromAppProps) => {
mdapiResponse={mdapiResponse}
mpapiResponse={mpapiResponse}
/>
<MaybeNewspaperArchiveInfo />

<PaymentFailureAlertIfApplicable
productDetails={allActiveProductDetails}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { InfoSummary } from '@guardian/source-development-kitchen/react-components';

export function MaybeNewspaperArchiveInfo() {
const urlSearchParams = new URLSearchParams(window.location.search);
const missingNewspaperArchiveEntitlement = urlSearchParams.get(
'missingNewspaperArchiveEntitlement',
);

return missingNewspaperArchiveEntitlement ? (
<InfoSummary
message="You do not have access to the Guardian's newspaper archive"
context="Subscribe to Digital + Print to get access"
/>
) : null;
}
3 changes: 1 addition & 2 deletions server/routes/newspaperArchive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ router.get('/auth', async (req: Request, res: Response) => {
const hasCorrectEntitlement = await checkSupporterEntitlement(req);

if (!hasCorrectEntitlement) {
// ToDo: show the user an error/info page
return res.redirect('/');
return res.redirect('/?missingNewspaperArchiveEntitlement=true');
}

const authHeader = base64(`${authString}`);
Expand Down

0 comments on commit cabb12f

Please sign in to comment.