Feature/api paramyxrx #25
1 changed files with 4 additions and 1 deletions
|
|
@ -2,12 +2,15 @@ export const validateMedicationApiKey = (req, res, next) => {
|
||||||
console.log('req: ', req);
|
console.log('req: ', req);
|
||||||
console.log('req.headers: ', req.headers);
|
console.log('req.headers: ', req.headers);
|
||||||
const authHeader = req.headers['authorization'];
|
const authHeader = req.headers['authorization'];
|
||||||
|
console.log('authHeader: ', authHeader);
|
||||||
const token = authHeader && authHeader.split(' ')[1];
|
const token = authHeader && authHeader.split(' ')[1];
|
||||||
|
console.log('token: ', token);
|
||||||
|
|
||||||
if (!token || token !== process.env.MEDICATION_API_KEY) {
|
if (!token || token !== process.env.MEDICATION_API_KEY) {
|
||||||
|
console.log('into the token not ok');
|
||||||
return res.status(401).json({ error: 'Unauthorized - Invalid API Key' });
|
return res.status(401).json({ error: 'Unauthorized - Invalid API Key' });
|
||||||
}
|
}
|
||||||
|
console.log('off to next');
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue