ShiftSync/api/middleware/auth.js

23 lines
793 B
JavaScript
Raw Normal View History

2026-01-18 04:56:42 +00:00
export const validateMedicationApiKey = (req, res, next) => {
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
2026-01-18 06:09:50 +00:00
2026-01-18 04:56:42 +00:00
if (!token || token !== process.env.MEDICATION_API_KEY) {
2026-01-18 06:09:50 +00:00
console.log('MEDICATION - User entered an Invalid token: ', token);
2026-01-18 04:56:42 +00:00
return res.status(401).json({ error: 'Unauthorized - Invalid API Key' });
}
next();
};
export const validateShiftSyncApiKey = (req, res, next) => {
const authHeader = req.headers['authorization'];
const token = authHeader && authHeader.split(' ')[1];
if (!token || token !== process.env.SHIFTSYNC_API_KEY) {
2026-01-18 06:09:50 +00:00
console.log('SHIFT - User entered an Invalid token: ', token);
2026-01-18 04:56:42 +00:00
return res.status(401).json({ error: 'Unauthorized - Invalid API Key' });
}
next();
};