mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🐛 Fix update:group in Bitwarden node (#1580)
* ⚡ Fix default args for update:group * ⚡ Add external IDs to resource loader
This commit is contained in:
parent
33c70153c8
commit
2ee5853bd0
|
@ -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') {
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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.<br>If set to true, this option overrides any collection assignments.',
|
||||
},
|
||||
{
|
||||
displayName: 'Collections',
|
||||
|
|
Loading…
Reference in a new issue