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:
Andreas Johansson 2024-04-14 14:28:42 +02:00 committed by GitHub
parent c1b6b941c7
commit e6ec996234
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 10 deletions

View File

@ -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 {

View File

@ -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 = {