➖ More unused code that pull credentials out of an object
Like why was this here, it's literally just object[key_name]
This commit is contained in:
parent
6cfb7e7e4d
commit
0d888a4c63
@ -43,15 +43,18 @@ exports.get_config = function(parser) {
|
|||||||
* @param {String} path | set to 'default' if we're using $HOME/.config/freechat/config.json
|
* @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
|
* 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') {
|
if (path == 'default') {
|
||||||
path = `${process.env.HOME || process.env.USERPROFILE}/.config/freechat/config.json`
|
path = `${process.env.HOME || process.env.USERPROFILE}/.config/freechat/config.json`
|
||||||
} else {
|
} else {
|
||||||
path = path
|
path = path
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = JSON.stringify(config)
|
const data = JSON.stringify(config, null, 2)
|
||||||
fs.writeFile(path, data)
|
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
|
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')
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user