From 6367f1ef052fc013715c8655604a3eda41803b31 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 16 Sep 2022 11:46:55 +0200 Subject: [PATCH] refator: delete sensitive info --- back/methods/osticket/closeTicket.js | 15 +++++++-------- back/models/osticket-config.json | 12 ++++++++++++ db/changes/10481-june/00-osTicketConfig.sql | 8 ++++++-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/back/methods/osticket/closeTicket.js b/back/methods/osticket/closeTicket.js index d742a265f..87d54d3b8 100644 --- a/back/methods/osticket/closeTicket.js +++ b/back/methods/osticket/closeTicket.js @@ -18,17 +18,16 @@ module.exports = Self => { Self.closeTicket = async ctx => { const models = Self.app.models; const config = await models.OsTicketConfig.findOne(); - - if (!config.user || !config.password) - return false; - const ostUri = `${config.host}/login.php`; + if (!config.user || !config.password || !config.userDb || !config.passwordDb) + return false; + const con = mysql.createConnection({ - host: 'localhost', - user: 'osticket', - password: 'osticket', - port: 40003 + host: `${config.hostDb}`, + user: `${config.userDb}`, + password: `${config.passwordDb}`, + port: `${config.portDb}` }); const sql = `SELECT ot.ticket_id, ot.number diff --git a/back/models/osticket-config.json b/back/models/osticket-config.json index 529d081c8..d42632c6a 100644 --- a/back/models/osticket-config.json +++ b/back/models/osticket-config.json @@ -35,6 +35,18 @@ }, "comment": { "type": "string" + }, + "hostDb": { + "type": "string" + }, + "userDb": { + "type": "string" + }, + "passwordDb": { + "type": "string" + }, + "portDb": { + "type": "number" } } } \ No newline at end of file diff --git a/db/changes/10481-june/00-osTicketConfig.sql b/db/changes/10481-june/00-osTicketConfig.sql index 36e55b003..ad6662715 100644 --- a/db/changes/10481-june/00-osTicketConfig.sql +++ b/db/changes/10481-june/00-osTicketConfig.sql @@ -8,9 +8,13 @@ CREATE TABLE `vn`.`osTicketConfig` ( `action` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `day` int(11) DEFAULT NULL, `comment` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `hostDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `userDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `passwordDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `portDb` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`) +INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`) VALUES - (0, 'http://localhost:56596/scp', '', '', 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente'); + (0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL); \ No newline at end of file