Fix crash issue and check if https in config
This commit is contained in:
parent
d55fd869fd
commit
ce029cc0e8
17
index.js
17
index.js
|
@ -12,7 +12,7 @@ if(config.https) {
|
||||||
protocol = "http://"
|
protocol = "http://"
|
||||||
}
|
}
|
||||||
|
|
||||||
if(port) {
|
if(port && !config.https) {
|
||||||
full_url = protocol + host + ":" + port
|
full_url = protocol + host + ":" + port
|
||||||
} else {
|
} else {
|
||||||
full_url = protocol + host
|
full_url = protocol + host
|
||||||
|
@ -204,11 +204,16 @@ app.get('/auth', function (req, res) {
|
||||||
};
|
};
|
||||||
request(options, function (error, response) {
|
request(options, function (error, response) {
|
||||||
if (error) console.log(error) && res.send("Error: Check console");
|
if (error) console.log(error) && res.send("Error: Check console");
|
||||||
res.cookie('oauth', JSON.parse(response.body)["access_token"], {
|
let body = JSON.parse(response.body)
|
||||||
maxAge: JSON.parse(response.body)["expires_in"] * 1000,
|
if(body["error"] || !body["access_token"]){
|
||||||
httpOnly: true
|
res.redirect('/')
|
||||||
});
|
} else {
|
||||||
res.render('pages/upload')
|
res.cookie('oauth', JSON.parse(response.body)["access_token"], {
|
||||||
|
maxAge: JSON.parse(response.body)["expires_in"] * 1000,
|
||||||
|
httpOnly: true
|
||||||
|
});
|
||||||
|
res.render('pages/upload')
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue