Davidgu/bug automatic link user to project on creation - #66
Open
shaply wants to merge 14 commits into
Open
Conversation
…JWT token is found in cookies
…he user for the project dynamic route
❌ Deploy Preview for juno-dashboard failed. Why did it fail? →
|
Contributor
Greptile OverviewGreptile SummaryFixes bug where users created on per-project pages weren't automatically linked to that project, causing them to disappear on page refresh. Key Changes:
Issues Found:
Confidence Score: 3/5
Important Files Changed
|
Comment on lines
+65
to
+87
| if (projectIds) { | ||
| const projectPromises: Promise<{success:boolean}>[] = []; | ||
|
|
||
| for (const projectId of projectIds) { | ||
| projectPromises.push( | ||
| linkUserToProjectId({ | ||
| projectId: projectId, | ||
| userId: String(result.user.id), | ||
| }) | ||
| ); | ||
| } | ||
| const linkResults = await Promise.all(projectPromises); | ||
| if (!newUser.projects) { | ||
| newUser.projects = []; | ||
| } | ||
| for (let i = 0; i < linkResults.length; i++) { | ||
| if (linkResults[i].success) { | ||
| newUser.projects.push(projectIds[i]); | ||
| } | ||
| } | ||
|
|
||
| newUser.projects = Array.from(new Set(newUser.projects)); | ||
| } |
Contributor
There was a problem hiding this comment.
No error handling if linkUserToProjectId fails - user will be created but not linked to project, reproducing the original bug
Suggested change
| if (projectIds) { | |
| const projectPromises: Promise<{success:boolean}>[] = []; | |
| for (const projectId of projectIds) { | |
| projectPromises.push( | |
| linkUserToProjectId({ | |
| projectId: projectId, | |
| userId: String(result.user.id), | |
| }) | |
| ); | |
| } | |
| const linkResults = await Promise.all(projectPromises); | |
| if (!newUser.projects) { | |
| newUser.projects = []; | |
| } | |
| for (let i = 0; i < linkResults.length; i++) { | |
| if (linkResults[i].success) { | |
| newUser.projects.push(projectIds[i]); | |
| } | |
| } | |
| newUser.projects = Array.from(new Set(newUser.projects)); | |
| } | |
| if (projectIds) { | |
| const projectPromises: Promise<{success:boolean}>[] = []; | |
| for (const projectId of projectIds) { | |
| projectPromises.push( | |
| linkUserToProjectId({ | |
| projectId: projectId, | |
| userId: String(result.user.id), | |
| }) | |
| ); | |
| } | |
| const linkResults = await Promise.all(projectPromises); | |
| if (!newUser.projects) { | |
| newUser.projects = []; | |
| } | |
| for (let i = 0; i < linkResults.length; i++) { | |
| if (linkResults[i].success) { | |
| newUser.projects.push(projectIds[i]); | |
| } else { | |
| console.error(`Failed to link user to project ${projectIds[i]}`); | |
| toast.error("Warning", { | |
| description: "User created but failed to link to project", | |
| }); | |
| } | |
| } | |
| newUser.projects = Array.from(new Set(newUser.projects)); | |
| } |
Contributor
Additional Comments (1)
|
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.
closes #41
Reproduction Steps
Fix
When a user is created on a per-project page, they should automatically be assigned to that particular project page.
Screen.Recording.2026-02-07.at.5.03.25.PM.mov