Whoops, forgot to remove Bearer
This commit is contained in:
parent
aa6ceb46b5
commit
76bd32a19f
4
index.js
4
index.js
|
@ -591,16 +591,14 @@ app.put('/api/v1/user/route', (req, res) => { // Update route
|
||||||
});
|
});
|
||||||
|
|
||||||
app.patch('/api/v1/user/update', async (req, res) => { // Update users server, port, auth, or secret via API key instead of session. Used for automated scripts
|
app.patch('/api/v1/user/update', async (req, res) => { // Update users server, port, auth, or secret via API key instead of session. Used for automated scripts
|
||||||
const apiKey = req.headers['authorization'];
|
const apiKey = req.headers['authorization'] ? req.headers['authorization'].replace('Bearer ', '') : null;
|
||||||
console.log(`API Key: ${apiKey}`);
|
console.log(`API Key: ${apiKey}`);
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
console.log("No API key provided");
|
|
||||||
res.status(401).json({ error: 'API Key is required!' });
|
res.status(401).json({ error: 'API Key is required!' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const oldData = await pool.query("SELECT * FROM routes WHERE apiKey = ?", [apiKey]);
|
const oldData = await pool.query("SELECT * FROM routes WHERE apiKey = ?", [apiKey]);
|
||||||
if (!oldData || oldData.length === 0) {
|
if (!oldData || oldData.length === 0) {
|
||||||
console.log("No data found for API key");
|
|
||||||
res.status(401).json({ error: 'Unauthorized' });
|
res.status(401).json({ error: 'Unauthorized' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue