From 0d888a4c634fb0112fb85072b00bbb7a99c7a145 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 7 Mar 2021 23:54:17 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9E=96=20More=20unused=20code=20that=20pull?= =?UTF-8?q?=20credentials=20out=20of=20an=20object=20Like=20why=20was=20th?= =?UTF-8?q?is=20here,=20it's=20literally=20just=20object[key=5Fname]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freechat-client/src/config.js | 45 +++++------------------------------ 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/freechat-client/src/config.js b/freechat-client/src/config.js index 35a9311..15f89a8 100644 --- a/freechat-client/src/config.js +++ b/freechat-client/src/config.js @@ -43,15 +43,18 @@ exports.get_config = function(parser) { * @param {String} path | set to 'default' if we're using $HOME/.config/freechat/config.json * Set this to anything else to write changes to that specified path */ -exports.update_config = function(config, path='default') { +exports.update_file = function(config, path='default') { if (path == 'default') { path = `${process.env.HOME || process.env.USERPROFILE}/.config/freechat/config.json` } else { path = path } - const data = JSON.stringify(config) - fs.writeFile(path, data) + const data = JSON.stringify(config, null, 2) + fs.writeFile(path, data, function(err) { + if(err) { console.error(err) } + else { console.log('fine') } + }) } /** @@ -66,39 +69,3 @@ exports.load_parser = function() { return parser } -/** - * NOTE: can possibly return undefined jwt values - * - * @param {String} domain | server config to search for jwt + id - * @param {String} key | basically are we looking for 'jwt' or 'secret' - */ -function get_creds(domain, key) { - let serv_id, serv_jwt - const config = ipcRenderer.sendSync('config-request') - for(const server in config['servers']) { - if(server['domain'] === domain) { - id = server['id'] - jwt = server[key] - } - } - return {id: serv_id, jwt: serv_jwt} -} - - -/** - * Attempts to grab the id + jwt values from the config - * NOTE: jwt key-value can realistically be undefined, or the JWT can be malformed/expired etc. - * @param {String} domain - */ -exports.jwt_creds = function(domain) { - return get_creds(domain, 'jwt') -} - -/** - * Attempts to pull id + secret values from the config - * - * @param {String} domain - */ -exports.basic_creds = function(domain) { - return get_creds(domain , 'secret') -}