diff --git a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts index 7b08eda740..4904329013 100644 --- a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts +++ b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts @@ -303,7 +303,7 @@ export class Bitwarden implements INodeType { // group: update // ---------------------------------- - const body = {} as IDataObject; + const groupId = this.getNodeParameter('groupId', i); const updateFields = this.getNodeParameter('updateFields', i) as GroupUpdateFields; @@ -311,7 +311,25 @@ export class Bitwarden implements INodeType { throw new Error(`Please enter at least one field to update for the ${resource}.`); } - const { name, collections, externalId, accessAll } = updateFields; + // set defaults for `name` and `accessAll`, required by Bitwarden but optional in n8n + + let { name, accessAll } = updateFields; + + if (name === undefined) { + responseData = await bitwardenApiRequest.call(this, 'GET', `/public/groups/${groupId}`, {}, {}) as { name: string }; + name = responseData.name; + } + + if (accessAll === undefined) { + accessAll = false; + } + + const body = { + name, + AccessAll: accessAll, + } as IDataObject; + + const { collections, externalId } = updateFields; if (collections) { body.collections = collections.map((collectionId) => ({ @@ -320,20 +338,11 @@ export class Bitwarden implements INodeType { })); } - if (name) { - body.name = name; - } - if (externalId) { body.externalId = externalId; } - if (accessAll !== undefined) { - body.AccessAll = accessAll; - } - - const id = this.getNodeParameter('groupId', i); - const endpoint = `/public/groups/${id}`; + const endpoint = `/public/groups/${groupId}`; responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); } else if (operation === 'updateMembers') { diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index 5e1c3e90c6..a46df9d46f 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -157,9 +157,9 @@ export async function loadResource( const { data } = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}, token); - data.forEach(({ id, name }: { id: string, name: string }) => { + data.forEach(({ id, name, externalId }: { id: string, name: string, externalId?: string }) => { returnData.push({ - name: name || id, + name: externalId || name || id, value: id, }); }); diff --git a/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts b/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts index aa6b4f07b5..b947a2ad3a 100644 --- a/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts +++ b/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts @@ -203,12 +203,12 @@ export const groupFields = [ placeholder: 'Add Field', default: {}, options: [ - { displayName: 'Access All', name: 'accessAll', type: 'boolean', default: false, + description: 'Allow this group to access all collections within the organization, instead of only its associated collections.
If set to true, this option overrides any collection assignments.', }, { displayName: 'Collections',