Two companies at go-live (INS, CV). Staff sign in with company + username + password; the stored login name is username@code. Super admins leave Company blank, belong to no company and see everything.
Companies screen (super admin only): create, edit name/status, rename code (renames staff login names and ends their sessions). Deactivating a company blocks its sign-in and ends its sessions.
Every /api/admin/** handler is scoped through AdminCompanyScope: lists and exports filter by the caller's company (super admin: chosen company or all); another company's record answers 404; creates need a concrete company.
Roles, interests (now one shared list), lockout settings and password rules: read for staff, write for super admins only.
Events and emails carry a company; login history and audit log are scoped (no-company rows only for super admins).
Portal: Company field on login/forgot-password, header company picker and Company column for super admins, company fields on create forms, read-only shared screens for staff.
Database
openspec/changes/add-company-scoping/sql/01..03 (+ 99-rollback.sql), mirrored in local/seed/03-colite.sql. 03 ends every admin session. See docs/deployment.md sections 3 and 10.
Live check on the local stack: INS and CV users with the same username each see only their own events, users, leads, emails, audit log and login history; admin sees both; a CV event/user by id answers 404 to INS.
Playwright (1280 px and 360 px): picker switching All/INS/CV, CV user created through the form, INS opening a CV event URL sees not-found, renaming CV's code signs the CV user out, deactivating CV blocks its sign-in.
Live check found and fixed: missing gateway route for /company/**, numeric companyId in String-valued backend filters, login history without the company, Company column blank when companies load after rows.
Known follow-ups (reviewed, accepted for now)
AdminCompanyScope.scope is fail-open for a company-less admin without role 1 (such users cannot be saved and none exist after the migration).
AppAccessAspect module bypass checks role 1 only.
Don't reuse a renamed company code while old sessions may be valid (documented).
Super-admin lead capture finds the event's company among the first 100 enabled events.
OpenSpec change `add-company-scoping` (design: `docs/superpowers/specs/2026-11-30-company-scoping-design.md`).
## What
- Two companies at go-live (INS, CV). Staff sign in with **company + username + password**; the stored login name is `username@code`. Super admins leave Company blank, belong to no company and see everything.
- Companies screen (super admin only): create, edit name/status, rename code (renames staff login names and ends their sessions). Deactivating a company blocks its sign-in and ends its sessions.
- Every `/api/admin/**` handler is scoped through `AdminCompanyScope`: lists and exports filter by the caller's company (super admin: chosen company or all); another company's record answers 404; creates need a concrete company.
- Roles, interests (now one shared list), lockout settings and password rules: read for staff, write for super admins only.
- Events and emails carry a company; login history and audit log are scoped (no-company rows only for super admins).
- Portal: Company field on login/forgot-password, header company picker and Company column for super admins, company fields on create forms, read-only shared screens for staff.
## Database
`openspec/changes/add-company-scoping/sql/01..03` (+ `99-rollback.sql`), mirrored in `local/seed/03-colite.sql`. `03` ends every admin session. See `docs/deployment.md` sections 3 and 10.
## Verification
- `mvn -T 1C -B verify` (all modules): BUILD SUCCESS — mobile-api 712, services-system 166, services-counter 148 tests.
- Portal: vitest 1349 passed, `tsc` 0, lint 0 errors, `next build` 0.
- Live check on the local stack: INS and CV users with the same username each see only their own events, users, leads, emails, audit log and login history; `admin` sees both; a CV event/user by id answers 404 to INS.
- Playwright (1280 px and 360 px): picker switching All/INS/CV, CV user created through the form, INS opening a CV event URL sees not-found, renaming CV's code signs the CV user out, deactivating CV blocks its sign-in.
- Live check found and fixed: missing gateway route for `/company/**`, numeric companyId in String-valued backend filters, login history without the company, Company column blank when companies load after rows.
## Known follow-ups (reviewed, accepted for now)
- `AdminCompanyScope.scope` is fail-open for a company-less admin without role 1 (such users cannot be saved and none exist after the migration).
- `AppAccessAspect` module bypass checks role 1 only.
- Don't reuse a renamed company code while old sessions may be valid (documented).
- Super-admin lead capture finds the event's company among the first 100 enabled events.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
OpenSpec change
add-company-scoping(design:docs/superpowers/specs/2026-11-30-company-scoping-design.md).What
username@code. Super admins leave Company blank, belong to no company and see everything./api/admin/**handler is scoped throughAdminCompanyScope: lists and exports filter by the caller's company (super admin: chosen company or all); another company's record answers 404; creates need a concrete company.Database
openspec/changes/add-company-scoping/sql/01..03(+99-rollback.sql), mirrored inlocal/seed/03-colite.sql.03ends every admin session. Seedocs/deployment.mdsections 3 and 10.Verification
mvn -T 1C -B verify(all modules): BUILD SUCCESS — mobile-api 712, services-system 166, services-counter 148 tests.tsc0, lint 0 errors,next build0.adminsees both; a CV event/user by id answers 404 to INS./company/**, numeric companyId in String-valued backend filters, login history without the company, Company column blank when companies load after rows.Known follow-ups (reviewed, accepted for now)
AdminCompanyScope.scopeis fail-open for a company-less admin without role 1 (such users cannot be saved and none exist after the migration).AppAccessAspectmodule bypass checks role 1 only.🤖 Generated with Claude Code
https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM