mirror of https://github.com/boxyhq/jackson.git
Handle group patches where value is a string (#2564)
Azure, and possibly others can send group name updates as ``` { "op": "replace", "path": "displayName", "value": "new-name" } ```
This commit is contained in:
parent
c1b6b941c7
commit
e6ec996234
|
@ -21,7 +21,7 @@ const parseUserRoles = (roles: string | string[]) => {
|
|||
export const parseGroupOperation = (operation: GroupPatchOperation) => {
|
||||
const { op, path, value } = operation;
|
||||
|
||||
if (path === 'members') {
|
||||
if (path === 'members' && typeof value == 'object') {
|
||||
if (op === 'add') {
|
||||
return {
|
||||
action: 'addGroupMember',
|
||||
|
@ -47,11 +47,18 @@ export const parseGroupOperation = (operation: GroupPatchOperation) => {
|
|||
}
|
||||
|
||||
// Update group name
|
||||
if (op === 'replace' && 'displayName' in value) {
|
||||
return {
|
||||
action: 'updateGroupName',
|
||||
displayName: value.displayName,
|
||||
};
|
||||
if (op === 'replace') {
|
||||
if (path == 'displayName' && typeof value == 'string') {
|
||||
return {
|
||||
action: 'updateGroupName',
|
||||
displayName: value,
|
||||
};
|
||||
} else if (typeof value == 'object' && 'displayName' in value) {
|
||||
return {
|
||||
action: 'updateGroupName',
|
||||
displayName: value.displayName,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -164,10 +164,12 @@ export type UserPatchOperation = {
|
|||
export type GroupPatchOperation = {
|
||||
op: 'add' | 'remove' | 'replace';
|
||||
path?: 'members' | 'displayName';
|
||||
value: {
|
||||
value: string;
|
||||
display?: string;
|
||||
}[];
|
||||
value:
|
||||
| string
|
||||
| {
|
||||
value: string;
|
||||
display?: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
export type GroupMembership = {
|
||||
|
|
Loading…
Reference in New Issue