10 lines
334 B
Plaintext
10 lines
334 B
Plaintext
// utils/auth.js
|
|
export function requireAuth(req, res, next) {
|
|
const token = req.headers['authorization']?.split(' ')[1];
|
|
if (!token || token !== process.env.DASHBOARD_TOKEN) {
|
|
return res.status(401).json({ error: 'Accès non autorisé' });
|
|
}
|
|
next();
|
|
}
|
|
|
|
export const isAdmin = (token) => token === process.env.ADMIN_TOKEN; |