mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Deduplicate encryption logic (#3434)
* ⚡ added function to credentials helper * Refactor function name * Fix lint issues Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
@@ -51,6 +51,8 @@ import {
|
||||
} from '.';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { User } from './databases/entities/User';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { CredentialsEntity } from './databases/entities/CredentialsEntity';
|
||||
|
||||
const mockNodeTypes: INodeTypes = {
|
||||
nodeTypes: {} as INodeTypeData,
|
||||
@@ -768,3 +770,14 @@ export async function getCredentialWithoutUser(
|
||||
const credential = await Db.collections.Credentials.findOne(credentialId);
|
||||
return credential;
|
||||
}
|
||||
|
||||
export function createCredentiasFromCredentialsEntity(
|
||||
credential: CredentialsEntity,
|
||||
encrypt = false,
|
||||
): Credentials {
|
||||
const { id, name, type, nodesAccess, data } = credential;
|
||||
if (encrypt) {
|
||||
return new Credentials({ id: null, name }, type, nodesAccess);
|
||||
}
|
||||
return new Credentials({ id: id.toString(), name }, type, nodesAccess, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user