mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
25a386dd70
* 🐛 Fix credential base url with trailing slash
* Fix credential test base url with trailing slash
55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
import type {
|
|
IAuthenticateGeneric,
|
|
ICredentialTestRequest,
|
|
ICredentialType,
|
|
INodeProperties,
|
|
} from 'n8n-workflow';
|
|
|
|
export class MattermostApi implements ICredentialType {
|
|
name = 'mattermostApi';
|
|
|
|
displayName = 'Mattermost API';
|
|
|
|
documentationUrl = 'mattermost';
|
|
|
|
properties: INodeProperties[] = [
|
|
{
|
|
displayName: 'Access Token',
|
|
name: 'accessToken',
|
|
type: 'string',
|
|
typeOptions: { password: true },
|
|
default: '',
|
|
},
|
|
{
|
|
displayName: 'Base URL',
|
|
name: 'baseUrl',
|
|
type: 'string',
|
|
default: '',
|
|
},
|
|
{
|
|
displayName: 'Ignore SSL Issues',
|
|
name: 'allowUnauthorizedCerts',
|
|
type: 'boolean',
|
|
description: 'Whether to connect even if SSL certificate validation is not possible',
|
|
default: false,
|
|
},
|
|
];
|
|
|
|
authenticate: IAuthenticateGeneric = {
|
|
type: 'generic',
|
|
properties: {
|
|
headers: {
|
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
|
},
|
|
},
|
|
};
|
|
|
|
test: ICredentialTestRequest = {
|
|
request: {
|
|
baseURL: '={{$credentials.baseUrl.replace(/\\/$/, "")}}/api/v4',
|
|
url: '/users',
|
|
skipSslCertificateValidation: '={{$credentials?.allowUnauthorizedCerts}}',
|
|
},
|
|
};
|
|
}
|