cs2-rcon-panel/modules/middleware.js
2023-09-28 10:53:33 +05:30

14 lines
399 B
JavaScript

function is_authenticated(req, res, next) {
if (req.session.user) {
next();
} else {
const accept_header = req.headers['accept'];
if (accept_header && accept_header.includes('text/html')) {
res.redirect('/');
} else {
res.status(401).json({ status: 401, message: 'Unauthorized' });
}
}
}
module.exports = is_authenticated;