mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ credentials update
This commit is contained in:
@@ -1,16 +1,9 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
IDataObject,
|
||||
INodeCredentialTestResult,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
@@ -45,7 +38,6 @@ export class Github implements INodeType {
|
||||
{
|
||||
name: 'githubApi',
|
||||
required: true,
|
||||
testedBy: 'githubApiTest',
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: ['accessToken'],
|
||||
@@ -1594,47 +1586,6 @@ export class Github implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
credentialTest: {
|
||||
async githubApiTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const credentials = credential.data;
|
||||
const baseUrl = (credentials!.server as string) || 'https://api.github.com';
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'User-Agent': 'n8n',
|
||||
Authorization: `token ${credentials!.accessToken}`,
|
||||
},
|
||||
uri: baseUrl.endsWith('/') ? baseUrl + 'user' : baseUrl + '/user',
|
||||
json: true,
|
||||
timeout: 5000,
|
||||
};
|
||||
try {
|
||||
const response = await this.helpers.request(options);
|
||||
if (!response.id) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: `Token is not valid: ${response.error}`,
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: `Settings are not valid: ${error}`,
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: 'OK',
|
||||
message: 'Authentication successful!',
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
Reference in New Issue
Block a user