Skip to content

feat(auth): support the __override view-as login (insight#1941) - #220

Merged
cyberantonz merged 1 commit into
constructorfabric:mainfrom
cyberantonz:feat/override-view-as
Jul 27, 2026
Merged

feat(auth): support the __override view-as login (insight#1941)#220
cyberantonz merged 1 commit into
constructorfabric:mainfrom
cyberantonz:feat/override-view-as

Conversation

@cyberantonz

Copy link
Copy Markdown
Contributor

Summary

Companion to constructorfabric/insight#1944 (authenticator __override view-as, restoring constructorfabric/insight#1941).

  • Historical URL keeps working: ?__override=<email> on any page is consumed at boot (src/auth/override.ts, wired in main.tsx before mocks/session/router) and bounced into /auth/login?__override=...&return_to=<page without the param>. Works while already logged in — the authenticator's session-fixation guard revokes the presented session at the callback and the IdP hop is silent SSO.
  • Session store: /auth/me's impersonator_email (present only on view-as sessions) is parsed into Session.impersonatorEmail.
  • "Viewing as X" banner (view-as-banner.tsx, next to the mock banner in the root layout): names the effective person and the real principal, with an Exit view-as button that simply re-logs-in as yourself.

Server-side the override is honored only where the authenticator's override_enabled flag is on (dev/demo stands); everywhere else the parameter is inert and this UI never renders.

Testing

  • npm test: 686 passed (new: override.test.ts bounce + no-op, session.test.ts impersonator parsing).
  • npm run typecheck + npm run build clean.
  • npm run lint: the 3 pre-existing problems in eslint-plugin-local/dist are unchanged (present on clean main); no new findings.

⚠️ Merge after (or together with) the backend PR — without it the banner never shows and __override is a harmless no-op.

🤖 Generated with Claude Code

Companion to the authenticator change (constructorfabric/insight#1944)
restoring the operator 'view the dashboard as another user' facility:

- The historical URL keeps working: '?__override=<email>' on any page is
  consumed at boot and bounced into /auth/login?__override=...&return_to=
  (the parameter itself never enters the router). Works while already
  logged in — the authenticator revokes the presented session at the
  callback and the IdP hop is silent SSO.
- /auth/me's 'impersonator_email' (present only on view-as sessions) is
  parsed into the session store.
- A 'Viewing as X' banner renders above the content on view-as sessions,
  naming the real principal, with an exit button that just re-logs-in as
  yourself.

The override is honored server-side only where the authenticator's
'override_enabled' flag is on (dev/demo stands); everywhere else the
parameter is inert and this UI never shows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Anton Zelenov <antonz@constructor.tech>
@cyberantonz
cyberantonz requested a review from a team as a code owner July 27, 2026 10:18
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 51 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e13a1c33-f78e-4368-a417-893947d057d2

📥 Commits

Reviewing files that changed from the base of the PR and between 7e7d63f and 7a9db43.

📒 Files selected for processing (11)
  • src/auth/index.ts
  • src/auth/override.test.ts
  • src/auth/override.ts
  • src/auth/session.test.ts
  • src/auth/session.ts
  • src/auth/types.ts
  • src/components/view-as-banner.tsx
  • src/locales/en/translation.json
  • src/main.tsx
  • src/routes/__root.tsx
  • src/test/session.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@cyberantonz
cyberantonz merged commit bcbb752 into constructorfabric:main Jul 27, 2026
5 of 6 checks passed
@cyberantonz
cyberantonz deleted the feat/override-view-as branch July 28, 2026 07:57
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.

3 participants