Init cs2 rcon panel
This commit is contained in:
14
modules/middleware.js
Normal file
14
modules/middleware.js
Normal file
@@ -0,0 +1,14 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user