Fix crash issue and check if https in config

This commit is contained in:
moom0o 2023-04-08 12:49:20 -04:00 committed by GitHub
parent d55fd869fd
commit ce029cc0e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -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')
}
});
})