mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 01:57:45 +03:00
CLI import credentials supports decrypted data
This commit is contained in:
parent
873e566489
commit
7eb849b9f7
@ -3,6 +3,11 @@ import {
|
||||
flags,
|
||||
} from '@oclif/command';
|
||||
|
||||
import {
|
||||
Credentials,
|
||||
UserSettings,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
Db,
|
||||
GenericHelpers,
|
||||
@ -64,7 +69,15 @@ export class ImportCredentialsCommand extends Command {
|
||||
throw new Error(`File does not seem to contain credentials.`);
|
||||
}
|
||||
|
||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
||||
if (encryptionKey === undefined) {
|
||||
throw new Error('No encryption key got found to encrypt the credentials!');
|
||||
}
|
||||
for (i = 0; i < fileContents.length; i++) {
|
||||
if (typeof fileContents[i].data === 'object') {
|
||||
// plain data / decrypted input. Should be encrypted first.
|
||||
Credentials.prototype.setData.call(fileContents[i], fileContents[i].data, encryptionKey);
|
||||
}
|
||||
await Db.collections.Credentials!.save(fileContents[i]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user