mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Load credentials from the database (#1741)
* Changes to types so that credentials can be always loaded from DB This first commit changes all return types from the execute functions and calls to get credentials to be async so we can use await. This is a first step as previously credentials were loaded in memory and always available. We will now be loading them from the DB which requires turning the whole call chain async. * Fix updated files * Removed unnecessary credential loading to improve performance * Fix typo * ⚡ Fix issue * Updated new nodes to load credentials async * ⚡ Remove not needed comment Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -221,7 +221,7 @@ export class BitbucketTrigger implements INodeType {
|
||||
// Get all the repositories to display them to user so that he can
|
||||
// select them easily
|
||||
async getRepositories(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const credentials = this.getCredentials('bitbucketApi');
|
||||
const credentials = await this.getCredentials('bitbucketApi');
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const repositories = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', `/repositories/${credentials!.username}`);
|
||||
for (const repository of repositories) {
|
||||
@@ -261,7 +261,7 @@ export class BitbucketTrigger implements INodeType {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
let endpoint = '';
|
||||
const credentials = this.getCredentials('bitbucketApi');
|
||||
const credentials = await this.getCredentials('bitbucketApi');
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
if (webhookData.webhookId === undefined) {
|
||||
@@ -292,7 +292,7 @@ export class BitbucketTrigger implements INodeType {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const events = this.getNodeParameter('events') as string[];
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
const credentials = this.getCredentials('bitbucketApi');
|
||||
const credentials = await this.getCredentials('bitbucketApi');
|
||||
|
||||
if (resource === 'user') {
|
||||
endpoint = `/users/${credentials!.username}/hooks`;
|
||||
@@ -318,7 +318,7 @@ export class BitbucketTrigger implements INodeType {
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
let endpoint = '';
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const credentials = this.getCredentials('bitbucketApi');
|
||||
const credentials = await this.getCredentials('bitbucketApi');
|
||||
const resource = this.getNodeParameter('resource', 0) as string;
|
||||
if (resource === 'user') {
|
||||
endpoint = `/users/${credentials!.username}/hooks/${webhookData.webhookId}`;
|
||||
|
||||
Reference in New Issue
Block a user