Built organization context switching for users
Designed an organization context‑switching system with client
localStorage and server‑side cookie mirroring, letting users act as
managed organizations while enforcing least‑privilege authorization.
2025

Situation. On the platform a maritime professional can manage
organizations — companies, academies — that don't have their own
logins. The person is the account; the organization is something
they act on behalf of. So a user needs to move through the whole app
as any organization they manage, switching between them freely, and
that convenience can't turn into a hole in the authorization.

Task. Context‑switching had to be quick and unobtrusive for the user
while making sure the active context could never, on its own, hand
someone access they weren't entitled to.

Action. An OrganizationContext handles it, with storage on both
sides. On the client, localStorage is the source of truth for which
organization you're currently acting as, so switching is instant —
no round‑trip. A server‑side cookie mirrors it so that
server‑rendered pages resolve the same context during SSR; there's a
getServerViewMode on the server that reads it. The important part is
that none of that is trusted for access decisions. Authorization
gets re‑checked on the server on every request. The frontend context
is there for the experience — showing you the right thing — and the
server is the only authority on what you're allowed to do.

Result. A user can act as any organization they manage without
friction, and the interface stays in sync on both client and server.
But because permissions are verified server‑side every time, none of
that convenience weakens the security. Someone tampering with what's
in localStorage changes what their own UI shows them and nothing
more — the server still says no.

Categories:
1Platform Architecture	/categories/platform-architecture/	platform.engineer.company	70
1Backend Engineering	/categories/backend/	platform.engineer.company	70
1Frontend Engineering	/categories/frontend/	platform.engineer.company	70
1Full‑Stack Development	/categories/full-stack/	platform.engineer.company	70
1APIs & Integration	/categories/api/	platform.engineer.company	70
1Security	/categories/security/	platform.engineer.company	70

Services:
1Platform & Solution Architecture	/services/platform-architecture/	platform.engineer.company	70
1Backend & API Development	/services/backend-development/	platform.engineer.company	70
1Frontend Development	/services/frontend-development/	platform.engineer.company	70
1Security & Access Management	/services/security-access/	platform.engineer.company	70

hThis page on the web	URL:https://platform.engineer.company/portfolio/built-organization-context-switching-for-users/	platform.engineer.company	70
