forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Store the organization id in credentials #5002
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
Merged
Merged
Conversation
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
jr
reviewed
Jun 22, 2025
jr
reviewed
Jun 22, 2025
|
||
if (storedOrgId !== null) { | ||
// User is in organization context - fetch user's memberships and filter | ||
const orgMemberships = await this.clerkGetOrganizationMemberships() |
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.
We could more simply just fetch https://clerk.com/docs/reference/frontend-api/tag/Organization#operation/getOrganization but I assume we plan to have a feature that would benefit from the role "soon enough" that it's worth continuing to fetch the memberships.
jr
reviewed
Jun 22, 2025
jr
reviewed
Jun 22, 2025
Address review feedback by properly handling 3 cases for organization_id: 1. Have an org id: send organization_id=THE_ORG_ID 2. Have a personal account: send organization_id= (empty string) 3. Don't know if you have an org id (old credentials): don't send organization_id param at all Changes: - Updated clerkCreateSessionToken() to check credentials.organizationId !== undefined - Updated fetchUserInfo() to handle all 3 cases consistently - Added fallback logic for old credentials without organization context - Improved logging for better debugging of organization context
Extract common organization membership processing logic into reusable helper methods: - findOrganizationMembership(): Find specific org membership by ID - findPrimaryOrganizationMembership(): Get first/primary org membership - setUserOrganizationInfo(): Set organization info on user object This eliminates duplication between the two clerkGetOrganizationMemberships() call sites that were doing very similar organization data processing.
jr
approved these changes
Jun 23, 2025
cte
pushed a commit
that referenced
this pull request
Jun 24, 2025
* Store the organization id in credentials * Better organization logic * Fix tests * Update cloud settings defaults * Fix organization_id handling in Clerk API calls Address review feedback by properly handling 3 cases for organization_id: 1. Have an org id: send organization_id=THE_ORG_ID 2. Have a personal account: send organization_id= (empty string) 3. Don't know if you have an org id (old credentials): don't send organization_id param at all Changes: - Updated clerkCreateSessionToken() to check credentials.organizationId !== undefined - Updated fetchUserInfo() to handle all 3 cases consistently - Added fallback logic for old credentials without organization context - Improved logging for better debugging of organization context * DRY up organization loading code in AuthService Extract common organization membership processing logic into reusable helper methods: - findOrganizationMembership(): Find specific org membership by ID - findPrimaryOrganizationMembership(): Get first/primary org membership - setUserOrganizationInfo(): Set organization info on user object This eliminates duplication between the two clerkGetOrganizationMemberships() call sites that were doing very similar organization data processing.
Alorse
pushed a commit
to Alorse/Roo-Code
that referenced
this pull request
Jun 27, 2025
* Store the organization id in credentials * Better organization logic * Fix tests * Update cloud settings defaults * Fix organization_id handling in Clerk API calls Address review feedback by properly handling 3 cases for organization_id: 1. Have an org id: send organization_id=THE_ORG_ID 2. Have a personal account: send organization_id= (empty string) 3. Don't know if you have an org id (old credentials): don't send organization_id param at all Changes: - Updated clerkCreateSessionToken() to check credentials.organizationId !== undefined - Updated fetchUserInfo() to handle all 3 cases consistently - Added fallback logic for old credentials without organization context - Improved logging for better debugging of organization context * DRY up organization loading code in AuthService Extract common organization membership processing logic into reusable helper methods: - findOrganizationMembership(): Find specific org membership by ID - findPrimaryOrganizationMembership(): Get first/primary org membership - setUserOrganizationInfo(): Set organization info on user object This eliminates duplication between the two clerkGetOrganizationMemberships() call sites that were doing very similar organization data processing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
lgtm
This PR has been approved by a maintainer
PR - Draft / In Progress
size:L
This PR changes 100-499 lines, ignoring generated files.
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.
Important
Add organization ID handling to authentication and MDM compliance checks.
organizationId
toauthCredentialsSchema
inAuthService.ts
.handleCallback()
to acceptorganizationId
and store it in credentials.getStoredOrganizationId()
to retrieve stored organization ID.clerkCreateSessionToken()
to handle organization ID cases.fetchUserInfo()
to set organization info based on stored ID.handleAuthCallback()
to passorganizationId
toAuthService
.hasStoredOrganizationId()
andgetStoredOrganizationId()
to retrieve organization ID.isCompliant()
inMdmService.ts
to check organization ID compliance.AuthService.spec.ts
andCloudService.test.ts
to test organization ID handling.MdmService.spec.ts
to test compliance with organization ID.This description was created by
for b2542e3. You can customize this summary. It will automatically update as commits are pushed.