feat(byra): gate the automatic cockpit landing to owner/admin (#1970)

* feat(byra): gate the automatic cockpit landing to owner/admin

Plain byra members now land like regular users; owner/admin keep the
cockpit landing at both decision sites (post-login /api/clients/landing
and the '/' bounce). The middleware zero-company steer stays ungated:
a member with zero companies has nowhere else to land. Cockpit access
itself is unchanged (nav + /clients remain membership-based).

Supersedes the 2026-08-05 all-members widening (DECISIONS.md).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(byra): keep byra members out of the first-run wizard on auto-landing

Skeptic finding: a member whose auto-resolved active company is
onboarding-incomplete (e.g. mid migration-reset, which repoints
active_company_id itself) fell through the new role gate into
/onboarding, a dead end for role member (WL-15 refuses client
creation). Byra members without a picked-company cookie now go to
/byra at the onboarding check, restoring the pre-gate shield.

Also pins the role column into the landing route's select assertion
so dropping it can't pass the mocked tests silently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mattsson
2026-08-27 11:49:00 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 23776337c8
commit b30c71086e
7 changed files with 193 additions and 14 deletions
+4 -2
View File
@@ -499,8 +499,10 @@ async function updateSessionInner(
return supabaseResponse
}
// Byrå team members (any role: widened from owner/admin, founder call
// 2026-08-05) with zero client companies (a fresh byrå) home to the
// Byrå team members (any role: deliberately NOT gated by
// isCockpitLandingRole even after the 2026-08-27 owner/admin landing
// gate, because a plain member with zero companies has nowhere else to
// land) with zero client companies (a fresh byrå) home to the
// EMPTY cockpit, never to the company onboarding wizard: clients are
// created from the cockpit, and forcing the wizard here would make a
// byrå user create a personal company just to get in. Cockpit-shaped