fix(api): enrol the dev session user in the workspace - #194
Open
phanlemanh wants to merge 1 commit into
Open
Conversation
dev-session writes the session row straight through Prisma, so better-auth's session.create.before hook never runs and the user never gets a member row. Every workspace-scoped call then answers 'You are not a member of this workspace' — the connections page 500s on it. Call the same helper the hook calls, and carry activeOrganizationId the way it does.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@phanlemanh is attempting to deploy a commit to the Comp AI - PoC Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bun run dev:session me@example.commints a session that the app then rejects with"You are not a member of this workspace." — the connections page 500s on it, and so
does anything else workspace-scoped.
The script writes the session row straight through Prisma, so better-auth's
session.create.beforehook never runs, and that hook is what callsensureWorkspaceMembership. A brand-new dev user therefore never gets amemberrow.It only looks like it works on a workspace that still has zero members, where the
backfill branch enrols everyone who already exists.
Two lines: call the same helper the hook calls, and carry
activeOrganizationIdthesame way it does.
Summary by cubic
Fixes dev sessions so
bun run dev:sessionmints sessions the app accepts. The script wrote session rows directly through Prisma, skipping thesession.create.beforehook that callsensureWorkspaceMembership, so new dev users were never enrolled in a workspace and workspace-scoped calls rejected them with "You are not a member of this workspace." The script now calls the same helper and setsactiveOrganizationIdthe same way the hook does.Written for commit 1c47c66. Summary will update on new commits.