diff --git a/.env.example b/.env.example index 8d6f17e..2a11349 100644 --- a/.env.example +++ b/.env.example @@ -17,9 +17,9 @@ SMTP_FROM="CommunityRule " # /privacy. Unset or any value other than `true` is off (404, no footer/login/email links). # Staging: `true`. Production stays off until university counsel has read the policy. -# ENABLE_PRIVACY_POLICY is the Cloudron runtime switch. The NEXT_PUBLIC_ alias bakes at image build. +# Only ENABLE_PRIVACY_POLICY counts. It is read at runtime on Cloudron. +# A build-time NEXT_PUBLIC_ENABLE_PRIVACY_POLICY value does not turn the page on. # ENABLE_PRIVACY_POLICY=true -# NEXT_PUBLIC_ENABLE_PRIVACY_POLICY=true # CR-107: inbox for Ask an organizer form submissions (requires CLOUDRON_MAIL_SMTP_* in production). ORGANIZER_INQUIRY_TO= diff --git a/docs/guides/ops-backend-deploy.md b/docs/guides/ops-backend-deploy.md index 9a9d4e8..3183f5e 100644 --- a/docs/guides/ops-backend-deploy.md +++ b/docs/guides/ops-backend-deploy.md @@ -81,8 +81,8 @@ per-app in the manifest and provisioned at install time. - `ENABLE_PRIVACY_POLICY=true` — turns on `/privacy` at runtime. Staging keeps this on so counsel can read the page. Leave unset in production until that review is done (the route 404s and public chrome does not - link to it). `NEXT_PUBLIC_ENABLE_PRIVACY_POLICY` is the same switch - baked at image build; prefer the runtime name on Cloudron. + link to it). Only this runtime name counts. A build-time + `NEXT_PUBLIC_ENABLE_PRIVACY_POLICY` value does not turn the page on. - `NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true` — turns on Postgres draft persistence for signed-in users. Required in production. - `UPLOAD_ROOT` — absolute path to a writable directory on the Cloudron diff --git a/lib/privacyPolicyEnabled.ts b/lib/privacyPolicyEnabled.ts index 3a6c4f4..94186aa 100644 --- a/lib/privacyPolicyEnabled.ts +++ b/lib/privacyPolicyEnabled.ts @@ -1,13 +1,11 @@ /** - * `/privacy` stays off in production until university counsel has read the - * policy. Staging sets `ENABLE_PRIVACY_POLICY=true` (or the public alias). + * `/privacy` stays off until university counsel has read the policy. + * Only the runtime switch `ENABLE_PRIVACY_POLICY=true` turns it on. + * A build-time `NEXT_PUBLIC_ENABLE_PRIVACY_POLICY` value does not. * Unset or any other value is off. */ export function isPrivacyPolicyEnabled(): boolean { - return ( - process.env.ENABLE_PRIVACY_POLICY === "true" || - process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY === "true" - ); + return process.env.ENABLE_PRIVACY_POLICY === "true"; } /** Absolute /privacy URL, or null while the flag is off. */ diff --git a/stories/navigation/Footer.responsive.stories.js b/stories/navigation/Footer.responsive.stories.js index 8d9dbf0..faa92e9 100644 --- a/stories/navigation/Footer.responsive.stories.js +++ b/stories/navigation/Footer.responsive.stories.js @@ -188,6 +188,9 @@ export const FullHD = { // Interactive story for testing user interactions export const Interactive = { + args: { + privacyEnabled: true, + }, parameters: { docs: { description: { diff --git a/tests/unit/privacyPolicyEnabled.test.ts b/tests/unit/privacyPolicyEnabled.test.ts index a414106..c544a7a 100644 --- a/tests/unit/privacyPolicyEnabled.test.ts +++ b/tests/unit/privacyPolicyEnabled.test.ts @@ -35,6 +35,10 @@ describe("isPrivacyPolicyEnabled", () => { delete process.env.ENABLE_PRIVACY_POLICY; process.env.NEXT_PUBLIC_ENABLE_PRIVACY_POLICY = "true"; + expect(isPrivacyPolicyEnabled()).toBe(false); + expect(privacyPolicyUrl("https://communityrule.info")).toBeNull(); + + process.env.ENABLE_PRIVACY_POLICY = "true"; expect(isPrivacyPolicyEnabled()).toBe(true); }); });