-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
fix: Enhance SCIM payload handling and attribute creation #18427
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (12/31/24)1 reviewer was added to this PR based on Keith Williams's automation. |
E2E results are ready! |
67dd2d8
to
63013d4
Compare
- Introduced a new PR_TODO.md file to track ongoing tasks and fixes. - Updated `getAttributesFromScimPayload` to accept a directoryId and ignore core user attributes during syncing. - Modified `handleUserEvents` to pass directoryId when syncing custom attributes. - Improved attribute creation logic to handle unique options and added support for optional isGroup property in attribute options. - Added utility function `getOptionsWithValidContains` to ensure valid sub-options in attribute options. - Updated tests to reflect changes in attribute handling and ensure proper functionality. This commit addresses issues with user attribute syncing and enhances the overall attribute management process.
- Introduced a new test file for the getOptionsWithValidContains function. - Added tests to verify the removal of duplicate options, initialization of empty contains arrays, filtering of non-existent sub-options, and handling of empty options arrays. - Ensured comprehensive coverage of the utility's functionality to enhance reliability and maintainability.
@@ -69,11 +69,6 @@ const handleUserEvents = async (event: DirectorySyncEvent, organizationId: numbe | |||
select: dSyncUserSelect, | |||
}); | |||
|
|||
// User is already a part of that org | |||
if (user && UserRepository.isAMemberOfOrganization({ user, organizationId }) && eventData.active) { |
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.
It was causing the update to not sync attribues as the user is already a part of org.
org, | ||
directoryId, | ||
}); | ||
if (UserRepository.isAMemberOfOrganization({ user, organizationId })) { |
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.
Still allow attributes sync for existing user.
@@ -28,8 +29,8 @@ const createAttributesHandler = async ({ input, ctx }: GetOptions) => { | |||
} | |||
|
|||
const slug = slugify(input.name); | |||
const options = input.options.map((v) => v.value); | |||
const optionsWithoutDuplicates = Array.from(new Set(options)); | |||
const uniqueOptions = getOptionsWithValidContains(input.options); |
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.
Using common utility
@@ -4,7 +4,7 @@ export const createAttributeSchema = z.object({ | |||
name: z.string(), | |||
type: z.enum(["TEXT", "NUMBER", "SINGLE_SELECT", "MULTI_SELECT"]), | |||
isLocked: z.boolean().optional(), | |||
options: z.array(z.object({ value: z.string() })), | |||
options: z.array(z.object({ value: z.string(), isGroup: z.boolean().optional() })), |
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.
It was causing a groupOption to become regular option when created during the attribute creation itself.
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.
LGTM!
Detailed Changes:
getAttributesFromScimPayload
to acceptdirectoryId
and ignore core attributes as defined in the SCIM spec.handleUserEvents
to passdirectoryId
when callinggetAttributesFromScimPayload
.getAttributesFromScimPayload
to reflect the new parameter and behavior.attributes-create-view.tsx
to streamline attribute submission.isGroup
property for options.getOptionsWithValidContains
to ensure valid sub-option references during attribute creation.These changes improve the robustness of user event handling and attribute management in the application.
What does this PR do?
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?