feat(vtiger-crm): add vtiger crm integration

This commit is contained in:
Rıdvan Akca
2024-01-03 14:25:12 +03:00
parent 953c5a5b5b
commit 57d5f34ac5
10 changed files with 1996 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
import verifyCredentials from './verify-credentials.js';
import isStillVerified from './is-still-verified.js';
export default {
fields: [
{
key: 'username',
label: 'Username',
type: 'string',
required: true,
readOnly: false,
value: null,
placeholder: null,
description: 'Email address of your Vtiger CRM account',
clickToCopy: false,
},
{
key: 'accessKey',
label: 'Access Key',
type: 'string',
required: true,
readOnly: false,
value: null,
placeholder: null,
description: 'Access Key of your Vtiger CRM account',
clickToCopy: false,
},
{
key: 'domain',
label: 'Domain',
type: 'string',
required: true,
readOnly: false,
value: null,
placeholder: null,
description:
'For example: acmeco.od1 if your dashboard url is https://acmeco.od1.vtiger.com. (Unfortunately, we are not able to offer support for self-hosted instances at this moment.)',
clickToCopy: false,
},
],
verifyCredentials,
isStillVerified,
};

View File

@@ -0,0 +1,8 @@
import verifyCredentials from './verify-credentials.js';
const isStillVerified = async ($) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -0,0 +1,32 @@
import crypto from 'crypto';
const verifyCredentials = async ($) => {
const params = {
operation: 'getchallenge',
username: $.auth.data.username,
};
const { data } = await $.http.get('/webservice.php', { params });
const accessKey = crypto
.createHash('md5')
.update(data.result.token + $.auth.data.accessKey)
.digest('hex');
const body = {
operation: 'login',
username: $.auth.data.username,
accessKey,
};
const { data: result } = await $.http.post('/webservice.php', body);
const response = await $.http.get('/restapi/v1/vtiger/default/me');
await $.auth.set({
screenName: `${response.data.result?.first_name} ${response.data.result?.last_name}`,
sessionName: result.result.sessionName,
});
};
export default verifyCredentials;