Skip to content

Commit

Permalink
Merge pull request #412 from Scrivito/fix_localStorage_in_incognito
Browse files Browse the repository at this point in the history
CookieConsent: Treat denied localStorage as "declined" cookie banner.
  • Loading branch information
dcsaszar authored Jul 5, 2021
2 parents 456029b + b4c17cf commit eff89bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/Components/CookieConsentContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@ export function useCookieConsent() {
}

function getCookieConsent() {
return localStorage.getItem("CookieConsent") || "undecided";
try {
return localStorage.getItem("CookieConsent") || "undecided";
} catch (e) {
if (e instanceof DOMException) {
// Prevent "Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document."
return "declined";
}

throw e;
}
}
4 changes: 2 additions & 2 deletions src/Objs/Homepage/HomepageEditingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Scrivito.provideEditingConfig("Homepage", {
],
},
cookieConsentLink: {
title: "Cookie consent link",
title: "Privacy policy for cookie consent",
description:
'If you set this link, a cookie consent box will be shown on every page. The link should point to your privacy policy. The link title defaults to "Learn more »".',
'If you set this link, a cookie consent box will be shown on every page. To preview the effect of this setting, please enable third-party cookies in your browser. The link title defaults to "Learn more »".',
},
},
properties: [...defaultPageProperties, "showAsLandingPage"],
Expand Down

0 comments on commit eff89bc

Please sign in to comment.