Skip to content

Fix auth legal navigation - #2330

Merged
Asherlc merged 2 commits into
mainfrom
Asherlc/issue-2101-auth-legal-navigation
Jul 30, 2026
Merged

Asherlc merged 2 commits into
mainfrom
Asherlc/issue-2101-auth-legal-navigation

Conversation

@Asherlc

@Asherlc Asherlc commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • add Terms of Service and Privacy Policy context to account creation on web and iOS
  • keep a stable home path on every responsive web authentication mode
  • allow signed-out users to read the existing Terms page
  • open native legal documents against the configured Dofek instance and report launch failures

Validation

  • pnpm test
  • pnpm lint
  • root, server, web, and mobile tsc --noEmit
  • focused web tests: 41 passed
  • focused mobile tests: 28 passed
  • pnpm --dir packages/web build
  • pnpm --dir packages/web build-storybook
  • pnpm --dir packages/mobile build-storybook
  • responsive web audit at 390×844
  • ad-hoc-signed Release iOS Simulator build, launch, and registration snapshot

Fixes #2101

Copilot AI review requested due to automatic review settings July 30, 2026 02:07
@codereviewbot-ai

Copy link
Copy Markdown

🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews.

@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Asherlc, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Asherlc, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7995c959-7aa6-48f2-8fa7-bd0d68668fac

📥 Commits

Reviewing files that changed from the base of the PR and between d644426 and 1ddd684.

📒 Files selected for processing (7)
  • docs/superpowers/plans/2026-07-29-auth-legal-navigation.md
  • packages/mobile/app/login.test.tsx
  • packages/mobile/app/login.tsx
  • packages/web/src/routes/-login.test.tsx
  • packages/web/src/routes/__root.test.tsx
  • packages/web/src/routes/__root.tsx
  • packages/web/src/routes/login.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds legal context and navigation for authentication flows on web and mobile, including Terms/Privacy disclosure during registration, stable home navigation on web, public access to legal routes, and native opening/reporting of legal documents, backed by new tests and a TDD plan document.

Sequence diagram for mobile legal document opening during registration

sequenceDiagram
  actor User
  participant LoginScreen
  participant Linking
  participant captureException

  User->>LoginScreen: tap TermsOfService link
  LoginScreen->>LoginScreen: openLegalDocument(terms)
  alt open succeeds
    LoginScreen->>Linking: openURL(serverUrl/terms)
    Linking-->>LoginScreen: resolved
  else open fails
    LoginScreen->>Linking: openURL(serverUrl/terms)
    Linking-->>LoginScreen: rejected error
    LoginScreen->>captureException: captureException(error, source login-screen-open-legal-document, document terms)
    LoginScreen->>User: [setError shows "Could not open the Terms of Service. Try again."]
  end

  User->>LoginScreen: tap PrivacyPolicy link
  LoginScreen->>LoginScreen: openLegalDocument(privacy)
  alt open succeeds
    LoginScreen->>Linking: openURL(serverUrl/privacy)
    Linking-->>LoginScreen: resolved
  else open fails
    LoginScreen->>Linking: openURL(serverUrl/privacy)
    Linking-->>LoginScreen: rejected error
    LoginScreen->>captureException: captureException(error, source login-screen-open-legal-document, document privacy)
    LoginScreen->>User: [setError shows "Could not open the Privacy Policy. Try again."]
  end
Loading

Flow diagram for web AuthGate public legal routes and login navigation

flowchart TD
  Request[Incoming request to web app]
  GetPath[Read location pathname]
  CheckPublic{{pathname in PUBLIC_PATHS}}
  CheckAuth{{user is authenticated}}
  Outlet[Render outlet content]
  Login[Navigate to /login]

  Request --> GetPath --> CheckPublic
  CheckPublic -->|yes: /, /login, /privacy, /reset-password, /terms| Outlet
  CheckPublic -->|no| CheckAuth
  CheckAuth -->|yes| Outlet
  CheckAuth -->|no| Login
Loading

File-Level Changes

Change Details Files
Add legal context and external opening behavior to mobile registration flow, with error reporting.
  • Import and mock React Native Linking in the mobile login tests to assert URL opening behavior.
  • Add an openLegalDocument helper in the mobile login screen that opens instance-relative legal URLs via Linking and captures/report errors to the user.
  • Render Terms of Service and Privacy Policy links with appropriate accessibility roles and styling when authMode is register.
  • Extend mobile login tests to cover presence of legal links, correct URL destinations, existing-account navigation, and error-reporting when opening fails.
packages/mobile/app/login.tsx
packages/mobile/app/login.test.tsx
Add legal context and stable home navigation to the web login route.
  • Wrap the login page in padded container to support the new top-level link layout.
  • Add a persistent "Back to Dofek" link at the top of the login card that always points to the home route.
  • Render Terms of Service and Privacy Policy links in registration mode, with same-origin hrefs and accent styling.
  • Extend web login tests to assert presence of legal links with correct hrefs, and verify home link visibility across login, register, and reset flows.
packages/web/src/routes/login.tsx
packages/web/src/routes/-login.test.tsx
Allow unauthenticated users to access legal routes on web.
  • Extend the set of public paths in the root auth gate to include the existing /terms route.
  • Add tests to confirm unauthenticated users can navigate to /privacy and /terms without being redirected to /login, while retaining other auth gate behavior.
packages/web/src/routes/__root.tsx
packages/web/src/routes/__root.test.tsx
Document the TDD plan and validation steps for auth legal navigation changes.
  • Create a plan document describing goals, behavior, scope, test strategy, file changes, tasks, and validation steps for auth legal navigation.
  • Record commands and checks used to validate the implementation across lint, tests, TypeScript builds, Storybook builds, and manual audits.
docs/superpowers/plans/2026-07-29-auth-legal-navigation.md

Assessment against linked issues

Issue Objective Addressed Explanation
#2101 Expose Terms of Service and Privacy Policy context/links in registration flows on both web and native mobile.
#2101 Ensure the registration flow clearly exposes an existing-account sign-in path.
#2101 Provide predictable back navigation on the responsive web login (a stable path back to the Dofek home page) and ensure legal pages are accessible to signed-out users.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix auth legal navigation across web and iOS registration

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Show Terms/Privacy disclosure during registration on web and iOS login screens.
• Keep a stable “Back to Dofek” home link across all web auth modes.
• Allow signed-out access to /terms; add targeted web and mobile coverage.
Diagram

graph TD
  U([User]) --> W["Web login route"] --> H["Home page"]
  W --> L["Legal docs (/terms,/privacy)"]
  U --> G["Web AuthGate"] --> L
  M["Mobile login screen"] --> K["Linking.openURL"] --> S["Configured serverUrl"] --> L
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use URL() to join serverUrl + path (avoid string concatenation)
  • ➕ Avoids double-slash and missing-slash edge cases with configured origins
  • ➕ Makes URL construction intent explicit and easier to validate/test
  • ➖ Slightly more code; may require polyfill considerations in some RN environments
2. Open legal documents in an in-app WebView modal instead of external browser
  • ➕ Keeps users in-app; smoother UX and fewer context switches
  • ➕ More control over error handling, loading states, and theming
  • ➖ More implementation and maintenance cost
  • ➖ Requires additional security/privacy review for embedded browsing
3. Centralize legal-link rendering into shared UI primitives (web + mobile)
  • ➕ Ensures consistent copy/labels and reduces duplicated legal UX logic
  • ➕ Easier to evolve legal navigation rules in one place
  • ➖ Cross-package abstraction may be overkill for two small UIs
  • ➖ Can introduce coupling between platform-specific presentation layers

Recommendation: The PR’s minimal, test-driven approach is appropriate for a navigation bugfix. Consider a small follow-up to construct mobile legal URLs via new URL(path, serverUrl) to harden against trailing-slash configuration edge cases; the rest of the implementation is well-scoped and validated by focused tests.

Files changed (7) +289 / -3

Enhancement (2) +87 / -1
login.tsxShow legal disclosure in registration and open policies via configured instance +60/-0

Show legal disclosure in registration and open policies via configured instance

• Adds registration-only legal context with accessible links for Terms of Service and Privacy Policy. Implements 'openLegalDocument()' to open '${serverUrl}/{terms|privacy}', capturing exceptions and displaying a user-facing error on failure.

packages/mobile/app/login.tsx

login.tsxAdd persistent home link and registration legal disclosure on web auth UI +27/-1

Add persistent home link and registration legal disclosure on web auth UI

• Adds a top-level "Back to Dofek" link to keep a stable escape path from all auth modes and adjusts layout padding for responsive contexts. Shows registration-only legal disclosure with links to /terms and /privacy using consistent copy.

packages/web/src/routes/login.tsx

Bug fix (1) +1 / -1
__root.tsxMake /terms a public route for signed-out users +1/-1

Make /terms a public route for signed-out users

• Updates the AuthGate public-path allowlist to include /terms alongside existing public routes. This prevents redirect-to-login behavior when accessing the Terms page anonymously.

packages/web/src/routes/__root.tsx

Tests (3) +129 / -1
login.test.tsxAdd mobile registration legal-link and failure-handling tests +66/-1

Add mobile registration legal-link and failure-handling tests

• Extends LoginScreen tests to assert Terms/Privacy links appear during registration, open instance-relative URLs via 'Linking.openURL', and surface/report errors when launch fails. Also verifies the existing-account sign-in path remains available from registration.

packages/mobile/app/login.test.tsx

-login.test.tsxCover web registration legal links and persistent home navigation +45/-0

Cover web registration legal links and persistent home navigation

• Adds tests ensuring registration mode renders canonical same-origin links to /terms and /privacy and preserves a named sign-in path. Also verifies a "Back to Dofek" home link stays visible across login, registration, and reset flows.

packages/web/src/routes/-login.test.tsx

__root.test.tsxVerify anonymous access to legal routes via AuthGate +18/-0

Verify anonymous access to legal routes via AuthGate

• Adds parameterized coverage asserting unauthenticated users can visit both /privacy and /terms without being redirected to /login, ensuring legal pages remain readable when signed out.

packages/web/src/routes/__root.test.tsx

Documentation (1) +72 / -0
2026-07-29-auth-legal-navigation.mdAdd TDD plan for authentication legal navigation behavior +72/-0

Add TDD plan for authentication legal navigation behavior

• Documents the intended cross-client behavior for Terms/Privacy links during registration, stable home navigation on web auth, and anonymous access to legal routes. Captures scope constraints and a validation checklist aligned with the implemented tests.

docs/superpowers/plans/2026-07-29-auth-legal-navigation.md

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Mobile Preview

Scan to open on device:

QR code for dofek://preview/pr-2330

Channel pr-2330
Deep Link dofek://preview/pr-2330
Commit 74551a7

To test on device:

  1. Build and install the preview client: PREVIEW_CHANNEL=pr-2330 pnpm expo prebuild --clean -p ios
  2. Or tap deep link on an existing preview build: dofek://preview/pr-2330

Each PR gets its own channel. Build a preview client with PREVIEW_CHANNEL=pr-{N} to test.

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Storybook previews for 74551a71 are ready:

This comment updates automatically on each PR push.

@qodo-code-review

qodo-code-review Bot commented Jul 30, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 186 rules

Grey Divider


Remediation recommended

1. Legal error persists ✓ Resolved 🐞 Bug ☼ Reliability
Description
LoginScreen.openLegalDocument() sets the shared error banner on failure but never clears it on
retry/success, so a transient Linking.openURL failure can leave a misleading error message visible
even after the user successfully opens a policy later.
Code

packages/mobile/app/login.tsx[R139-149]

+  async function openLegalDocument(document: "privacy" | "terms") {
+    const documentTitle = document === "privacy" ? "Privacy Policy" : "Terms of Service";
+    try {
+      await Linking.openURL(`${serverUrl}/${document}`);
+    } catch (error_: unknown) {
+      captureException(error_, {
+        source: "login-screen-open-legal-document",
+        document,
+      });
+      setError(`Could not open the ${documentTitle}. Try again.`);
+    }
Relevance

●●● Strong

Team has accepted fixes for persistent stale error messages; e.g., clear WHOOP syncMessage after
user fixes inputs (PR 2296).

PR-#2296
PR-#2045
PR-#728

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new openLegalDocument() only calls setError(...) in its catch block and never resets it;
the banner is rendered whenever error is non-null, while other auth actions explicitly clear the
error at the start of work.

packages/mobile/app/login.tsx[139-150]
packages/mobile/app/login.tsx[197-201]
packages/mobile/app/login.tsx[100-105]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`openLegalDocument()` sets `error` when `Linking.openURL(...)` fails, but never clears `error` when a new attempt starts or when it succeeds. This can leave stale failure UI visible after a later successful policy launch.

## Issue Context
`error` is rendered as a banner near the top of the screen and is also reused by other auth flows. Most other async actions clear the banner at the start of an attempt.

## Fix Focus Areas
- packages/mobile/app/login.tsx[139-150]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment thread packages/mobile/app/login.tsx
@codereviewbot-ai

Copy link
Copy Markdown

🤖 Review skipped: Repository rate limit exceeded. Free accounts are limited to 2 reviews per 4 hours per repository. Upgrade to a paid plan for unlimited reviews.

@Asherlc
Asherlc merged commit 3211946 into main Jul 30, 2026
100 checks passed
@Asherlc
Asherlc deleted the Asherlc/issue-2101-auth-legal-navigation branch July 30, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AUTH-05] Registration lacks Privacy/Terms; web mobile login lacks back path

2 participants