mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix: Apply credential overwrites recursively (#5072)
This ensures that overwrites defined for a parent credential type also applies to all credentials extending it.
This commit is contained in:
committed by
GitHub
parent
f1184ccab5
commit
5d746c4a83
@@ -1,3 +1,4 @@
|
||||
import uniq from 'lodash.uniq';
|
||||
import {
|
||||
CUSTOM_EXTENSION_ENV,
|
||||
UserSettings,
|
||||
@@ -8,6 +9,7 @@ import {
|
||||
Types,
|
||||
} from 'n8n-core';
|
||||
import type {
|
||||
ICredentialTypes,
|
||||
ILogger,
|
||||
INodesAndCredentials,
|
||||
KnownNodesAndCredentials,
|
||||
@@ -46,6 +48,8 @@ export class LoadNodesAndCredentialsClass implements INodesAndCredentials {
|
||||
|
||||
includeNodes = config.getEnv('nodes.include');
|
||||
|
||||
credentialTypes: ICredentialTypes;
|
||||
|
||||
logger: ILogger;
|
||||
|
||||
async init() {
|
||||
@@ -68,8 +72,21 @@ export class LoadNodesAndCredentialsClass implements INodesAndCredentials {
|
||||
async generateTypesForFrontend() {
|
||||
const credentialsOverwrites = CredentialsOverwrites().getAll();
|
||||
for (const credential of this.types.credentials) {
|
||||
const overwrittenProperties = [];
|
||||
this.credentialTypes
|
||||
.getParentTypes(credential.name)
|
||||
.reverse()
|
||||
.map((name) => credentialsOverwrites[name])
|
||||
.forEach((overwrite) => {
|
||||
if (overwrite) overwrittenProperties.push(...Object.keys(overwrite));
|
||||
});
|
||||
|
||||
if (credential.name in credentialsOverwrites) {
|
||||
credential.__overwrittenProperties = Object.keys(credentialsOverwrites[credential.name]);
|
||||
overwrittenProperties.push(...Object.keys(credentialsOverwrites[credential.name]));
|
||||
}
|
||||
|
||||
if (overwrittenProperties.length) {
|
||||
credential.__overwrittenProperties = uniq(overwrittenProperties);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user