trails/apps/journal/app/lib
Ullrich Schäfer f16e80a2eb
Prompt users with stale terms_version to re-accept
The three pre-legal-disclaimer users (ullrich, pistazie, nelli) have
NULL terms_version, and any future Terms update would leave every
existing user in the same state. Close the loop now that we have
version storage by redirecting any logged-in user whose
users.terms_version doesn't match the currently-published
TERMS_VERSION to a dedicated acceptance page.

Changes:
- auth.server: new recordTermsAcceptance(userId, version) helper that
  writes both terms_accepted_at and terms_version.
- root loader: if the session user has a stale or NULL terms_version,
  throw redirect("/auth/accept-terms?returnTo=<pathname>") unless the
  request is already on an allow-listed path
  (/auth/accept-terms, /auth/logout, /legal/*) so Terms are reachable
  and logout works.
- New route /auth/accept-terms (GET renders the prompt, POST records
  acceptance and bounces to a sanitised returnTo). Same-origin check
  on returnTo to avoid open-redirect abuse. Logout button is provided
  as an escape hatch.
- i18n: new auth.reaccept.* keys for EN and DE.
- Spec: new Requirement + five scenarios (redirect, allow-list,
  successful re-accept, missing consent, returnTo sanitisation).

No action on the three legacy users is required beyond what they'll
experience on their next visit — the gate takes care of it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 08:06:16 +02:00
..
sync Fix Wahoo import bugs, add Import All, update spec 2026-04-05 17:47:48 +02:00
activities.server.ts Fix lint: duration is never reassigned, use const 2026-04-05 20:04:10 +02:00
api-guard.server.ts Implement Journal REST API v1 endpoints 2026-04-13 00:57:27 +02:00
auth.server.ts Prompt users with stale terms_version to re-accept 2026-04-19 08:06:16 +02:00
db.ts Implement Journal auth: passkeys + magic links, no passwords 2026-03-23 17:38:46 +01:00
email.server.test.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
email.server.ts Add 6-digit login code for mobile authentication 2026-04-15 20:56:42 +02:00
jwt.server.ts Implement Planner-Journal handoff (Group 9) 2026-03-24 20:22:58 +00:00
legal.ts Store Terms version alongside acceptance timestamp 2026-04-19 07:46:34 +02:00
logger.server.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
metrics.server.ts Add observability: health endpoints, structured logging, metrics, Grafana stack 2026-03-26 22:59:44 +01:00
oauth.server.test.ts Implement OAuth2 PKCE auth, discovery, and mobile API client 2026-04-13 00:41:40 +02:00
oauth.server.ts Implement Journal REST API v1 endpoints 2026-04-13 00:57:27 +02:00
operator.ts Add legal pages, ToS acceptance, and alpha banner 2026-04-18 00:08:48 +02:00
routes.server.ts Sync notes through GPX, Journal, and Planner roundtrip 2026-04-11 03:35:40 +02:00
sentry.client.ts Stop Sentry on logout; fix E2E + Dockerfile for merged consolidation 2026-04-18 00:40:36 +02:00