mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 04:41:09 +02:00
Switching to a non-personal space then refreshing reverted to Personal: GET http://localhost:3001/api/auth/organization/get-active-member → 400 Bad Request (NO_ACTIVE_ORGANIZATION) Dev-mode cross-origin + SameSite=Lax means the Set-Cookie from Better Auth's /organization/set-active response is quietly dropped by the browser. The server's session record never gets activeOrganizationId updated, so on the next page load get-active-member throws BAD_REQUEST with NO_ACTIVE_ORGANIZATION — and my fallback promoted Personal, reverting the user's explicit choice. Fix: client-side localStorage hint that mirrors the server preference. loadActiveSpace(): 1. Ask the server (get-active-member) — trust it if it knows the org. 2. Otherwise fetch the org list + read the hint from localStorage. If the hint matches an org the user is actually a member of, call set-active again to re-sync the server and use that org. 3. Only fall back to Personal when there's no hint (truly fresh session or first-login). writeActiveSpaceHint() is called from: - SpaceSwitcher.switchTo() — on explicit switch. - SpaceCreateDialog — on successful create (the user just chose it). - accept-invitation — on accept (user opted in to the new space). - loadActiveSpace() itself — after any successful resolve, so the hint stays current. Exported from $lib/data/scope so additional flows (admin tools, future delete-space) can keep it in sync. Production impact: once COOKIE_DOMAIN=.mana.how is set with SameSite=None+Secure, the server cookie takes precedence and the hint is redundant but harmless. 0 errors across 7234 files. Plan: docs/plans/spaces-foundation.md |
||
|---|---|---|
| .. | ||
| api | ||
| calc/packages/shared | ||
| calendar | ||
| cards | ||
| chat | ||
| citycorners | ||
| contacts | ||
| context | ||
| docs | ||
| food | ||
| guides | ||
| inventory | ||
| mana | ||
| manavoxel | ||
| memoro | ||
| moodlit | ||
| mukke | ||
| news | ||
| photos | ||
| picture | ||
| plants | ||
| presi | ||
| questions | ||
| quotes/packages/content | ||
| skilltree | ||
| storage | ||
| times | ||
| todo | ||
| traces | ||
| uload | ||