Fixed updated auth handling
This commit is contained in:
@@ -24,17 +24,19 @@ app.all(/.*/, (req, res) => {
|
||||
let hazePwHash = null;
|
||||
let hazeUser = null;
|
||||
if (req.query.auth) {
|
||||
request({
|
||||
let api_data = {
|
||||
...reqOpts,
|
||||
url: reqOpts.url + req.baseUrl,
|
||||
headers: {
|
||||
Authorization: `Basic ${req.query.auth}`
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
};
|
||||
request(api_data, (error, response, body) => {
|
||||
if (error) {
|
||||
res.status(500).send('Internal Server Error');
|
||||
return;
|
||||
} else if (response.statusCode !== 200) {
|
||||
console.dir(api_data);
|
||||
res.status(response.statusCode).send(body);
|
||||
return;
|
||||
} else {
|
||||
@@ -42,9 +44,12 @@ app.all(/.*/, (req, res) => {
|
||||
res.send(body);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
res.status(401).send('Unauthorized');
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running on http://localhost:${port}`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user