mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Change credentials structure (#2139)
* ✨ change FE to handle new object type * 🚸 improve UX of handling invalid credentials * 🚧 WIP * 🎨 fix typescript issues * 🐘 add migrations for all supported dbs * ✏️ add description to migrations * ⚡ add credential update on import * ⚡ resolve after merge issues * 👕 fix lint issues * ⚡ check credentials on workflow create/update * update interface * 👕 fix ts issues * ⚡ adaption to new credentials UI * 🐛 intialize cache on BE for credentials check * 🐛 fix undefined oldCredentials * 🐛 fix deleting credential * 🐛 fix check for undefined keys * 🐛 fix disabling edit in execution * 🎨 just show credential name on execution view * ✏️ remove TODO * ⚡ implement review suggestions * ⚡ add cache to getCredentialsByType * ⏪ use getter instead of cache * ✏️ fix variable name typo * 🐘 include waiting nodes to migrations * 🐛 fix reverting migrations command * ⚡ update typeorm command * ✨ create db:revert command * 👕 fix lint error Co-authored-by: Mutasem <mutdmour@gmail.com>
This commit is contained in:
@@ -738,16 +738,20 @@ export async function requestOAuth2(
|
||||
|
||||
credentials.oauthTokenData = newToken.data;
|
||||
|
||||
// Find the name of the credentials
|
||||
// Find the credentials
|
||||
if (!node.credentials || !node.credentials[credentialsType]) {
|
||||
throw new Error(
|
||||
`The node "${node.name}" does not have credentials of type "${credentialsType}"!`,
|
||||
);
|
||||
}
|
||||
const name = node.credentials[credentialsType];
|
||||
const nodeCredentials = node.credentials[credentialsType];
|
||||
|
||||
// Save the refreshed token
|
||||
await additionalData.credentialsHelper.updateCredentials(name, credentialsType, credentials);
|
||||
await additionalData.credentialsHelper.updateCredentials(
|
||||
nodeCredentials,
|
||||
credentialsType,
|
||||
credentials,
|
||||
);
|
||||
|
||||
Logger.debug(
|
||||
`OAuth2 token for "${credentialsType}" used by node "${node.name}" has been saved to database successfully.`,
|
||||
@@ -955,25 +959,26 @@ export async function getCredentials(
|
||||
} as ICredentialsExpressionResolveValues;
|
||||
}
|
||||
|
||||
let name = node.credentials[type];
|
||||
const nodeCredentials = node.credentials[type];
|
||||
|
||||
if (name.charAt(0) === '=') {
|
||||
// If the credential name is an expression resolve it
|
||||
const additionalKeys = getAdditionalKeys(additionalData);
|
||||
name = workflow.expression.getParameterValue(
|
||||
name,
|
||||
runExecutionData || null,
|
||||
runIndex || 0,
|
||||
itemIndex || 0,
|
||||
node.name,
|
||||
connectionInputData || [],
|
||||
mode,
|
||||
additionalKeys,
|
||||
) as string;
|
||||
}
|
||||
// TODO: solve using credentials via expression
|
||||
// if (name.charAt(0) === '=') {
|
||||
// // If the credential name is an expression resolve it
|
||||
// const additionalKeys = getAdditionalKeys(additionalData);
|
||||
// name = workflow.expression.getParameterValue(
|
||||
// name,
|
||||
// runExecutionData || null,
|
||||
// runIndex || 0,
|
||||
// itemIndex || 0,
|
||||
// node.name,
|
||||
// connectionInputData || [],
|
||||
// mode,
|
||||
// additionalKeys,
|
||||
// ) as string;
|
||||
// }
|
||||
|
||||
const decryptedDataObject = await additionalData.credentialsHelper.getDecrypted(
|
||||
name,
|
||||
nodeCredentials,
|
||||
type,
|
||||
mode,
|
||||
false,
|
||||
|
||||
Reference in New Issue
Block a user