OrgSwitcher
Dropdown of the user’s organization memberships with a click-to-switch
action. Switching calls AuthClient.switchOrg(orgId) which:
- Refreshes the access token with the new
organization_id. - Emits the
org_switchedevent for subscribers. - Updates the auth snapshot’s claims so consumers gating UI on
claims.org_idreact automatically.
The current org is read from the claims; the dropdown highlights it.
Membership is verified server-side every switch, so a stale
MyOrgRecord from getMyOrgs() won’t grant unauthorized access.
Usage
import { OrgSwitcher } from '@rw3iss/auth-client/preact/forms';
<OrgSwitcher onError={(err) => console.error(err)}/>Props
| Name | Type | Description |
|---|---|---|
client | AuthClient | |
onSwitch | (org: MyOrgRecord) => void | |
onError | (err: Error) => void | |
className | string |