mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
`GET /api/auth/me` grows an `accountAccess` block: the accounts this caller may act on, the one the browser is inside right now, and the booleans a UI binds directly — `canSwitch`, and `canWrite` per account. Every value is resolved server-side. A client that worked out what it may do from grant rows would be a second program deciding one person's access to a health record, and the two answer differently the first time an expiry or a revocation appears. `canWrite` is false for every grant in v1 because invitations write READ only. It is resolved through the grant state machine rather than hardcoded, so the day a WRITE grant exists the answer changes without this file being edited. The route becomes an actor surface. It has to be: the switcher, the banner naming whose record is open, and the way back out all read this payload, and under a bare `requireAuth()` the whole app shell would refuse the moment a switch was on. Every field it returns is still the caller's own. The active record is published as a full entry, not an id to look up. A banner that had to join two fields could render unnamed the moment they disagreed; here the active entry is one of the listed ones, selected by the pass that built them. A stamp left behind by a grant that lapsed reads as not switched — the same answer the resolver gives the next delegated request. Not published: the other account's avatar. Those bytes are owner-scoped, so a URL here would resolve to a refusal and paint a broken image. Clients keep the initials fallback.