-
Notifications
You must be signed in to change notification settings - Fork 926
web: fix org setup when skipping to dashboard during onboarding #1255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe Onboarding.skipToDashboard flow now conditionally creates a new organization and owner/member only when the current user's activeOrganizationId has no matching organization; it then updates the user's Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User
participant Frontend
participant Backend
participant DB
User->>Frontend: Click "Skip to Dashboard"
Frontend->>Backend: POST /onboarding/skipToDashboard
Backend->>DB: SELECT organization WHERE id = user.activeOrganizationId
alt organization exists
DB-->>Backend: organization row
Backend->>DB: UPDATE users SET activeOrganizationId/defaultOrgId = existingOrg.id
DB-->>Backend: OK
Backend-->>Frontend: 200 (redirect to dashboard)
else no organization found
Backend->>DB: INSERT INTO organizations (ownerId, ...) -> newOrg.id
DB-->>Backend: newOrg.id
Backend->>DB: INSERT INTO organization_members (orgId, userId, role=owner)
DB-->>Backend: OK
Backend->>DB: UPDATE users SET activeOrganizationId = newOrg.id, defaultOrgId = newOrg.id
DB-->>Backend: OK
Backend-->>Frontend: 200 (redirect to dashboard)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/web-backend/src/Users/UsersOnboarding.ts (1)
283-288
: Consider checkingdefaultOrgId
as a fallback for consistency.The
organizationSetup
method checks bothuser.activeOrganizationId
anduser.defaultOrgId
as a fallback (line 90), butskipToDashboard
only queries usingcurrentUser.activeOrganizationId
. If a user has noactiveOrganizationId
but has adefaultOrgId
, this could lead to creating a duplicate organization instead of using the existing one.For consistency with the
organizationSetup
method, consider:+const orgIdToCheck = user.activeOrganizationId ?? user.defaultOrgId; + const [existingOrg] = await tx .select() .from(Db.organizations) .where( - Dz.eq(Db.organizations.id, currentUser.activeOrganizationId), + Dz.eq(Db.organizations.id, orgIdToCheck), );Note: You may also want to add a null check before the query if
orgIdToCheck
could be null, or structure it as:let existingOrg = null; const orgIdToCheck = user.activeOrganizationId ?? user.defaultOrgId; if (orgIdToCheck) { [existingOrg] = await tx .select() .from(Db.organizations) .where(Dz.eq(Db.organizations.id, orgIdToCheck)); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/web-backend/src/Users/UsersOnboarding.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}
: Use a 2-space indent for TypeScript code.
Use Biome for formatting and linting TypeScript/JavaScript files by runningpnpm format
.Use strict TypeScript and avoid any; leverage shared types
Files:
packages/web-backend/src/Users/UsersOnboarding.ts
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx}
: Use kebab-case for filenames for TypeScript/JavaScript modules (e.g.,user-menu.tsx
).
Use PascalCase for React/Solid components.
Files:
packages/web-backend/src/Users/UsersOnboarding.ts
🧬 Code graph analysis (1)
packages/web-backend/src/Users/UsersOnboarding.ts (2)
packages/web-domain/src/Organisation.ts (1)
Organisation
(8-11)packages/database/helpers.ts (1)
nanoId
(6-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
- GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
- GitHub Check: Analyze (rust)
Summary by CodeRabbit
Bug Fixes
New Features