get_channels now has nearly no logic in it
Doing this because there are other mechanisms in place to protect against bs JWT's which really just adds a ton of complexity to every function
This commit is contained in:
parent
e693d7e62b
commit
316b5ad1fd
@ -1,4 +1,5 @@
|
|||||||
// Requesting channel data here
|
// Requesting channel data here
|
||||||
|
const { ipcRenderer } = require('electron')
|
||||||
const auth = require('./auth.js')
|
const auth = require('./auth.js')
|
||||||
const { Request } = require('./request.js')
|
const { Request } = require('./request.js')
|
||||||
|
|
||||||
@ -20,30 +21,30 @@ class Channel {
|
|||||||
* @param {Object} params | basic object with jwt + id fields
|
* @param {Object} params | basic object with jwt + id fields
|
||||||
*/
|
*/
|
||||||
function channels_list(domain, port, params) {
|
function channels_list(domain, port, params) {
|
||||||
const url = `http://${domain}:${port}/channels/list` // input sanitzation is for bitches
|
|
||||||
Request('get', url, params).then(
|
Request('get', domain, port, '/channels/list', params).then(
|
||||||
response => {
|
channels => {
|
||||||
const channels = response.body
|
// fill the DOM with stuff here
|
||||||
console.log(channels)
|
console.log('sucess', channels)
|
||||||
},
|
},
|
||||||
reason => {
|
reason => {
|
||||||
|
console.log('Request for /channels/list rejected', reason)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only requests
|
* Listener callback for actually getting a list of channels
|
||||||
* @param {Object} server_conf Should contain at least id/secret + domain/port
|
* @param {Object} server_conf Should contain at least id/secret + domain/port
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
exports.get_channels = function(server_conf) {
|
exports.get_channels = function(server_conf) {
|
||||||
// the first two checks are here to rpevent getting a 401 due to a bad/missing jwt
|
// the first two checks are here to rpevent getting a 401 due to a bad/missing jwt
|
||||||
if('jwt' in server_conf) {
|
console.log(server_conf)
|
||||||
if(auth.valid_jwt(server['jwt'])) {
|
const params = {
|
||||||
const params = { jwt: server['jwt'], id: server['id'] }
|
id: server_conf['id'],
|
||||||
}
|
jwt: server_conf['jwt']
|
||||||
// do something else idk
|
|
||||||
} else {
|
|
||||||
// complain here
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channels_list(server_conf['domain'], server_conf['port'], params)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user