+ );
+}
+
+/**
+ * Full-page login shell for magic-link **error redirects** (`?error=*`) and direct `/login` visits.
+ * Header **Log in** uses `AuthModalProvider` instead; this route stays for verify failures and bookmarks.
+ */
+export default function LoginPageClient({
+ privacyEnabled,
+}: {
+ privacyEnabled: boolean;
+}) {
+ return (
+ }>
+
+
+ );
+}
diff --git a/app/(app)/login/page.tsx b/app/(app)/login/page.tsx
index d9f0241..72bebdc 100644
--- a/app/(app)/login/page.tsx
+++ b/app/(app)/login/page.tsx
@@ -1,64 +1,6 @@
-"use client";
-
-import { Suspense } from "react";
-import Link from "next/link";
-import { useRouter } from "next/navigation";
-import { useTranslation } from "../../contexts/MessagesContext";
-import Login from "../../components/modals/Login";
-import LoginForm from "../../components/modals/Login/LoginForm";
-
-const loginPageBgClass =
- "min-h-[100dvh] bg-[var(--color-surface-invert-brand-primary)]";
-
-function LoginLoadingFallback() {
- const t = useTranslation("pages.login");
- return (
-
-
- {t("loadingFallback")}
-
-
- );
-}
-
-/**
- * Full-page login shell for magic-link **error redirects** (`?error=*`) and direct `/login` visits.
- * Header **Log in** uses `AuthModalProvider` instead; this route stays for verify failures and bookmarks.
- */
-function LoginWithSearchParams() {
- const router = useRouter();
- const t = useTranslation("pages.login");
- const closeToHome = () => {
- router.push("/");
- };
-
- return (
-
-
- {t("backToHome")}
-
- }
- >
-
-
-
- );
-}
+import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
+import LoginPageClient from "./LoginPageClient";
export default function LoginPage() {
- return (
- }>
-
-
- );
+ return ;
}
diff --git a/app/(dev)/layout.tsx b/app/(dev)/layout.tsx
index 7383768..d71bee0 100644
--- a/app/(dev)/layout.tsx
+++ b/app/(dev)/layout.tsx
@@ -5,6 +5,7 @@ import { MessagesProvider } from "../contexts/MessagesContext";
import { AuthModalProvider } from "../contexts/AuthModalContext";
import messages from "../../messages/en/index";
import { MAIN_CONTENT_ID } from "../../lib/mainContent";
+import { isPrivacyPolicyEnabled } from "../../lib/privacyPolicyEnabled";
import { NO_INDEX_ROBOTS } from "../../lib/siteMetadata";
export const metadata: Metadata = {
@@ -18,7 +19,7 @@ export default function DevLayout({ children }: { children: ReactNode }) {
}
return (
-
+
-
+
{/*
* Same session-aware shell as `(app)` / `(admin)`: `ConditionalNavigation`
* reads the cookie behind Suspense so the static page shell can prerender
diff --git a/app/(marketing)/privacy/page.tsx b/app/(marketing)/privacy/page.tsx
index 35efafc..11e2b86 100644
--- a/app/(marketing)/privacy/page.tsx
+++ b/app/(marketing)/privacy/page.tsx
@@ -3,8 +3,10 @@
* https://www.figma.com/design/agv0VBLiBlcnSAaiAORgPR/Community-Rule-System?node-id=19003-23305
*/
import type { Metadata } from "next";
+import { notFound } from "next/navigation";
import messages from "../../../messages/en/index";
import { legalPathForSlug } from "../../../lib/legalSyntheticPost";
+import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
import { routeMetadata } from "../../../lib/siteMetadata";
import LegalDocumentPage, {
legalPageMetadata,
@@ -14,6 +16,7 @@ const SLUG = "privacy" as const;
const PATH = legalPathForSlug(SLUG);
export function generateMetadata(): Metadata {
+ if (!isPrivacyPolicyEnabled()) notFound();
return routeMetadata(
PATH,
legalPageMetadata(messages.metadata.privacy, messages.pages.privacy),
@@ -21,6 +24,7 @@ export function generateMetadata(): Metadata {
}
export default function PrivacyPage() {
+ if (!isPrivacyPolicyEnabled()) notFound();
return (
-
+ void;
/** Sent-state Close, and the dialog chrome close. */
@@ -120,6 +122,7 @@ export type LoginFormProps = {
export default function LoginForm({
variant = "default",
magicLinkNextPath,
+ privacyEnabled = false,
onDismiss,
onClose,
}: LoginFormProps) {
@@ -365,13 +368,17 @@ export default function LoginForm({
>
{tFooter("legal.termsOfService")}
- {t("legalAnd")}
-
- {tFooter("legal.privacyPolicy")}
-
+ {privacyEnabled ? (
+ <>
+ {t("legalAnd")}
+
+ {tFooter("legal.privacyPolicy")}
+
+ >
+ ) : null}
{t("legalSuffix")}
>
diff --git a/app/components/navigation/Footer.tsx b/app/components/navigation/Footer.tsx
index 0fa2402..4ac9bc3 100644
--- a/app/components/navigation/Footer.tsx
+++ b/app/components/navigation/Footer.tsx
@@ -13,7 +13,13 @@ import { PRODUCTION_SITE_ORIGIN } from "../../../lib/siteMetadata";
* Tiers: smallest viewports (below `md`), `md` through `lg`, `lg` and up.
* Matches `--breakpoint-md: 640px`, `--breakpoint-lg: 1024px` in `app/tailwind.css`.
*/
-const Footer = memo(({ siteOrigin = PRODUCTION_SITE_ORIGIN }: { siteOrigin?: string }) => {
+const Footer = memo(({
+ siteOrigin = PRODUCTION_SITE_ORIGIN,
+ privacyEnabled = false,
+}: {
+ siteOrigin?: string;
+ privacyEnabled?: boolean;
+}) => {
const t = useTranslation("footer");
const tChrome = useTranslation("controlsChrome");
@@ -213,9 +219,11 @@ const Footer = memo(({ siteOrigin = PRODUCTION_SITE_ORIGIN }: { siteOrigin?: str
{t("takeaway")}
-
- {t("legal.privacyPolicy")}
-
+ {privacyEnabled ? (
+
+ {t("legal.privacyPolicy")}
+
+ ) : null}
{t("legal.termsOfService")}
diff --git a/app/components/navigation/FooterWithOrigin.tsx b/app/components/navigation/FooterWithOrigin.tsx
index bdb94a9..46175d0 100644
--- a/app/components/navigation/FooterWithOrigin.tsx
+++ b/app/components/navigation/FooterWithOrigin.tsx
@@ -1,8 +1,14 @@
import Footer from "./Footer";
+import { isPrivacyPolicyEnabled } from "../../../lib/privacyPolicyEnabled";
import { getRequestSiteOrigin } from "../../../lib/requestSiteOrigin";
/** Footer JSON-LD uses the request origin, same host as the page canonical. */
export default async function FooterWithOrigin() {
const siteOrigin = await getRequestSiteOrigin();
- return ;
+ return (
+
+ );
}
diff --git a/app/contexts/AuthModalContext.tsx b/app/contexts/AuthModalContext.tsx
index f7d4929..6e2dccc 100644
--- a/app/contexts/AuthModalContext.tsx
+++ b/app/contexts/AuthModalContext.tsx
@@ -39,7 +39,13 @@ type AuthModalContextValue = {
const AuthModalContext = createContext(null);
-export function AuthModalProvider({ children }: { children: ReactNode }) {
+export function AuthModalProvider({
+ children,
+ privacyEnabled = false,
+}: {
+ children: ReactNode;
+ privacyEnabled?: boolean;
+}) {
const tLogin = useTranslation("pages.login");
const [open, setOpen] = useState(false);
const [opts, setOpts] = useState({});
@@ -93,6 +99,7 @@ export function AuthModalProvider({ children }: { children: ReactNode }) {
diff --git a/docs/guides/ops-backend-deploy.md b/docs/guides/ops-backend-deploy.md
index f9703f9..9a9d4e8 100644
--- a/docs/guides/ops-backend-deploy.md
+++ b/docs/guides/ops-backend-deploy.md
@@ -75,8 +75,14 @@ per-app in the manifest and provisioned at install time.
- `SESSION_SECRET` — long random (`openssl rand -hex 32`). Required,
≥ 16 chars. Rotating it logs everyone out.
- `SMTP_FROM` — visible "From:" address on sign-in emails. Cloudron
- does not inject this. Use `hello@communityrule.info` (continuity
- with the legacy service; SES relay accepts it).
+ does not inject this. Use `CommunityRule `
+ (continuity with the legacy service; SES relay accepts it). A leftover
+ `Community Rule` display name is rewritten to one word.
+- `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.
- `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
@@ -444,7 +450,8 @@ production env vars, and verify the vertical slice before apex cutover
```bash
cloudron env set --app staging.communityrule.info \
SESSION_SECRET="$(openssl rand -hex 32)" \
- SMTP_FROM="Community Rule " \
+ SMTP_FROM="CommunityRule " \
+ ENABLE_PRIVACY_POLICY=true \
NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true \
UPLOAD_ROOT=/app/data/uploads
```
diff --git a/docs/guides/ops-runbook.md b/docs/guides/ops-runbook.md
index 28f3443..6f44879 100644
--- a/docs/guides/ops-runbook.md
+++ b/docs/guides/ops-runbook.md
@@ -246,7 +246,8 @@ persist across image updates unless changed:
| Variable | Purpose |
| -------- | ------- |
| `SESSION_SECRET` | Session cookie signing (≥ 16 chars). Rotating logs everyone out. |
-| `SMTP_FROM` | Visible From on sign-in emails (e.g. `Community Rule `). |
+| `SMTP_FROM` | Visible From on sign-in emails (e.g. `CommunityRule `). The app rewrites a leftover `Community Rule` display name to one word. |
+| `ENABLE_PRIVACY_POLICY` | `true` on staging so `/privacy` is reachable. Unset in production until counsel has read the policy (404, no public links). |
| `NEXT_PUBLIC_ENABLE_BACKEND_SYNC` | `true` in staging/production — Postgres draft persistence. |
| `UPLOAD_ROOT` | `/app/data/uploads` on Cloudron — required for file uploads. |
| `OPS_PRUNE_TOKEN` | Bearer token for `POST /api/ops/prune`. Unset hides the route. Optional; the daily scheduler runs the prune inside the container without it. |
@@ -283,7 +284,7 @@ That is expected. Recipients still authenticate the visible `From:` (`staging.ap
2. In **Cloudron** → *Domains* → `communityrule.info` → DNS, add those CNAMEs. Cloudron's Namecheap provider publishes them to the registrar. Confirm with `dig +short CNAME ._domainkey.communityrule.info`.
3. Optional but recommended for SPF alignment: add `include:amazonses.com` to the existing TXT SPF, e.g. `v=spf1 include:amazonses.com a:my.medlab.host ~all`. Do not remove `a:my.medlab.host` until you know nothing still sends directly from the box.
4. Leave DMARC at `p=reject` once DKIM verifies in SES; if a provider still quarantines after DKIM is live, inspect that provider's headers before relaxing DMARC.
-5. Retest: request a magic link to Gmail **and** a non-Gmail inbox (May First / university). Check spam. Staging From is `Community Rule `.
+5. Retest: request a magic link to Gmail **and** a non-Gmail inbox (May First / university). Check spam. Staging From is `CommunityRule `.
`SMTP_FROM` should stay the Cloudron mailbox (`staging.app@communityrule.info` on staging, `hello@communityrule.info` on the apex app). The app falls back to `CLOUDRON_MAIL_FROM` if `SMTP_FROM` is unset.
diff --git a/docs/privacy-policy-facts.md b/docs/privacy-policy-facts.md
index ac8bf91..1331466 100644
--- a/docs/privacy-policy-facts.md
+++ b/docs/privacy-policy-facts.md
@@ -1,8 +1,8 @@
# Privacy policy facts
Numbers and hosting details the new privacy policy leaves in brackets.
-Live `/privacy` stays on the current page until university counsel has
-read this text. Do not switch the route on from this file.
+Live `/privacy` stays behind `ENABLE_PRIVACY_POLICY` until university
+counsel has read this text. Do not switch the route on from this file.
## How long things are kept
@@ -53,6 +53,7 @@ See [`docs/guides/ops-runbook.md`](guides/ops-runbook.md) §9.3.
- `/privacy` can show the new policy only after university counsel has
read it, including the Colorado Open Records Act line, Terms, Cookies,
- the legal cards, and CC0 for cards and templates.
+ the legal cards, and CC0 for cards and templates. Flipping
+ `ENABLE_PRIVACY_POLICY=true` on production is that switch.
- An email to every account holder before a change to who can read Rules
is after launch. Nothing about who can read Rules changes at launch.
diff --git a/lib/privacyPolicyEnabled.ts b/lib/privacyPolicyEnabled.ts
new file mode 100644
index 0000000..3a6c4f4
--- /dev/null
+++ b/lib/privacyPolicyEnabled.ts
@@ -0,0 +1,17 @@
+/**
+ * `/privacy` stays off in production until university counsel has read the
+ * policy. Staging sets `ENABLE_PRIVACY_POLICY=true` (or the public alias).
+ * 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"
+ );
+}
+
+/** Absolute /privacy URL, or null while the flag is off. */
+export function privacyPolicyUrl(origin: string): string | null {
+ if (!isPrivacyPolicyEnabled()) return null;
+ return `${origin.replace(/\/$/, "")}/privacy`;
+}
diff --git a/lib/publicSitemap.ts b/lib/publicSitemap.ts
index ee1aa61..7538db8 100644
--- a/lib/publicSitemap.ts
+++ b/lib/publicSitemap.ts
@@ -1,5 +1,6 @@
import type { MetadataRoute } from "next";
import { getAllBlogPosts } from "./content";
+import { isPrivacyPolicyEnabled } from "./privacyPolicyEnabled";
import { sitemapUrl } from "./siteMetadata";
import { USE_CASE_DETAIL_SLUGS } from "./useCaseSyntheticPost";
@@ -26,7 +27,9 @@ const STATIC_PUBLIC_PATHS = [
export function buildPublicSitemap(
listedRules: ReadonlyArray<{ id: string; updatedAt: Date }> = [],
): MetadataRoute.Sitemap {
- const entries: MetadataRoute.Sitemap = STATIC_PUBLIC_PATHS.map((path) => ({
+ const entries: MetadataRoute.Sitemap = STATIC_PUBLIC_PATHS.filter(
+ (path) => path !== "/privacy" || isPrivacyPolicyEnabled(),
+ ).map((path) => ({
url: sitemapUrl(path),
}));
diff --git a/lib/server/magicLinkMail.ts b/lib/server/magicLinkMail.ts
index ce840ac..7bf1cf9 100644
--- a/lib/server/magicLinkMail.ts
+++ b/lib/server/magicLinkMail.ts
@@ -1,5 +1,6 @@
import { ASSETS, getAssetPath } from "../assetUtils";
import { MAGIC_LINK_TTL_MINUTES } from "../privacyRetention";
+import { mailLegalFooterHtml, mailLegalFooterUrls } from "./mailLegalFooter";
export const MAGIC_LINK_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
@@ -31,51 +32,54 @@ function originHost(origin: string): string {
}
}
-export function buildMagicLinkMail(
- input: MagicLinkMailInput,
+type BrandedVerifyMailCopy = {
+ verifyUrl: string;
+ origin: string;
+ subject: string;
+ previewText: string;
+ heading: string;
+ intro: string;
+ buttonLabel: string;
+ ignore: string;
+ why: string;
+};
+
+function buildBrandedVerifyMail(
+ copy: BrandedVerifyMailCopy,
): MagicLinkMailContent {
- const origin = input.origin.replace(/\/$/, "");
- const minutes = MAGIC_LINK_TTL_MINUTES;
- const subject = "Your login link for CommunityRule";
- const previewText = `It works once, for ${minutes} minutes.`;
- const heading = "Log in to CommunityRule";
- const intro = `Use the button to log in. It works once, for ${minutes} minutes.`;
- const ignore =
- "If you did not ask to log in, ignore this email. Nobody can log in without the link.";
+ const origin = copy.origin.replace(/\/$/, "");
+ const { aboutUrl, privacyUrl } = mailLegalFooterUrls(origin);
const madeBy =
"CommunityRule is made by the Media Economies Design Lab at the University of Colorado Boulder.";
- const privacyUrl = `${origin}/privacy`;
- const aboutUrl = `${origin}/about`;
const logoUrl = `${origin}${MAGIC_LINK_LOGO_PATH}`;
- const host = originHost(origin);
+ const href = escapeHtml(copy.verifyUrl);
const text = [
- heading,
+ copy.heading,
"",
- intro,
+ copy.intro,
"",
- `Log in: ${input.verifyUrl}`,
+ `${copy.buttonLabel}: ${copy.verifyUrl}`,
"",
- ignore,
+ copy.ignore,
"",
madeBy,
- `Privacy ${privacyUrl}`,
+ ...(privacyUrl ? [`Privacy ${privacyUrl}`] : []),
`About CommunityRule ${aboutUrl}`,
"",
- `Sent because you asked to log in at ${host}.`,
+ copy.why,
].join("\n");
- const href = escapeHtml(input.verifyUrl);
const html = `
-${escapeHtml(subject)}
+${escapeHtml(copy.subject)}