Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
3.7 KiB
3.7 KiB
Proposal
Why
Co-Lite goes live on 2027-01-15 with two test-run companies, INS and CV, and more are planned. Each company's staff must see only their own company's data, and one or more super admins must see and manage everything, including creating companies. Everything built so far assumes a single company: users, events, emails, login history and the audit log are unscoped, interests are per company, and there is no way to create a company or tell companies apart at sign-in. Approved design: docs/superpowers/specs/2026-11-30-company-scoping-design.md.
What Changes
- Companies:
companygains a uniquecodeand an active/inactivestatus. A new super-admin-only Companies screen lists, creates and edits companies. An inactive company's staff cannot sign in. - Sign-in: the admin login page asks for Company, Username and Password; a super admin leaves Company empty. Usernames and emails are unique within a company. Forgot password asks for the same company and username plus the email.
- Super admins: a super admin is a company-less admin user holding the super admin role. Company staff can never hold that role. There can be several super admins.
- Scoping: every admin read, write, export and detail lookup is limited to the caller's company: users, events, event leads, leads, emails, login history, locked users and the audit log. Another company's record answers 404. Super admins see all companies, can narrow to one, and pick the company when creating a company-owned record.
- Shared data: roles, interests, lockout settings and password rules are shared by all companies, and only super admins edit them. Interests become one shared list.
- Portal: a header company picker and a Company column for super admins; Company fields on the login, forgot-password, user and event forms; the Companies screen.
- BREAKING (sign-in): company staff must enter their company code to sign in. The deploy signs everyone out.
- Deploy SQL: company code/status,
company_idoneventandemail, the interest unique key, staff login names, INS and CV setup.
Capabilities
New Capabilities
company-scoping: companies, the Companies screen, company sign-in identity, super admins, and the rule that limits every admin view and action to the caller's company.
Modified Capabilities
admin-access: staff login and forgot password take a company.admin-users: company membership, per-company username and email uniqueness, super admin creation.admin-roles: editing roles becomes super admin only.lead-interests: one shared interest list, edited by super admins only.admin-login-security: unlock is limited to the caller's company; settings become super admin only.
Impact
- services-system: company entity, repository and endpoints; user lookup, save and uniqueness by login name; user search by company; login-history and locked-user filters by company.
- services-counter:
company_idon events; event queries by company; interest queries become shared; queries accept "all companies" for super admins. - service-email:
company_idon emails, set when an email is saved for a user; search by company. - services-log: audit search by company.
- mobile-api: login and forgot password with company; one company-scope helper used by every admin service; Companies API; super-admin-only guards on roles, interests and login-security settings.
- admin portal: login, forgot-password, header picker, Company column and fields, Companies screen, super-admin-only screens.
- Database: additive SQL in the change folder plus a data step for existing users, events and emails; mirrored in
local/seed/03-colite.sql. - Unchanged: services-auth, token format, members and the customer portal.