Apply also credential overwrites of parent and fix bug

This commit is contained in:
Jan Oberhauser
2020-09-12 21:13:57 +02:00
parent ac2e0040b0
commit 99f7eb2eca
3 changed files with 33 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ import {
} from 'n8n-workflow';
import {
CredentialTypes,
ICredentialsOverwrite,
GenericHelpers,
} from './';
@@ -49,7 +50,27 @@ class CredentialsOverwritesClass {
}
get(type: string): ICredentialDataDecryptedObject | undefined {
return this.overwriteData[type];
const credentialTypes = CredentialTypes();
const credentialTypeData = credentialTypes.getByName(type);
if (credentialTypeData === undefined) {
throw new Error(`The credentials of type "${type}" are not known.`);
}
if (credentialTypeData.extends === undefined) {
return this.overwriteData[type];
}
const overwrites: ICredentialDataDecryptedObject = {};
for (const credentialsTypeName of credentialTypeData.extends) {
Object.assign(overwrites, this.get(credentialsTypeName));
}
if (this.overwriteData[type] !== undefined) {
Object.assign(overwrites, this.overwriteData[type]);
}
return overwrites;
}
getAll(): ICredentialsOverwrite {