From ce029cc0e8782501a895e3c0a8c49878e20af25f Mon Sep 17 00:00:00 2001 From: moom0o <48740106+moom0o@users.noreply.github.com> Date: Sat, 8 Apr 2023 12:49:20 -0400 Subject: [PATCH] Fix crash issue and check if https in config --- index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d483c58..dff9b37 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ if(config.https) { protocol = "http://" } -if(port) { +if(port && !config.https) { full_url = protocol + host + ":" + port } else { full_url = protocol + host @@ -204,11 +204,16 @@ app.get('/auth', function (req, res) { }; request(options, function (error, response) { if (error) console.log(error) && res.send("Error: Check console"); - res.cookie('oauth', JSON.parse(response.body)["access_token"], { - maxAge: JSON.parse(response.body)["expires_in"] * 1000, - httpOnly: true - }); - res.render('pages/upload') + let body = JSON.parse(response.body) + if(body["error"] || !body["access_token"]){ + res.redirect('/') + } else { + res.cookie('oauth', JSON.parse(response.body)["access_token"], { + maxAge: JSON.parse(response.body)["expires_in"] * 1000, + httpOnly: true + }); + res.render('pages/upload') + } }); })