fix(api,web): separate workspace context from auth session #551
Reference in New Issue
Block a user
Delete Branch "feat/workspace-context-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
GET /api/workspacesendpoint (AuthGuard only, no WorkspaceGuard) that returns user workspace membershipssession.user.workspaceId/currentWorkspaceIdreads that were always undefinedAuthUsershared typeRoot Cause
BetterAuth returns only identity fields on session responses. The
workspaceId,currentWorkspaceId, andworkspaceRolefields onAuthUserwere alwaysundefinedbecause they don't exist in the database User model and BetterAuth has noadditionalFieldsconfig for them. This causedpersistWorkspaceId()to silently skip, leaving localStorage empty, which made everyWorkspaceGuard-protected endpoint fail with "Workspace ID is required".Test plan
Closes #534
🤖 Generated with Claude Code