Refactor logging implementation and enhance authentication logging

This commit is contained in:
2025-01-30 22:02:35 +01:00
parent 2ebf92a5d5
commit 23a6d9b10f
5 changed files with 38 additions and 27 deletions

View File

@@ -1,10 +1,12 @@
const basicAuth = require('basic-auth');
const logger = require('../logger');
const auth = (req, res, next) => {
if (req.session && req.session.user) {
return next();
} else {
res.status(401).send('Authentication required.');
logger.error('Unauthorized access attempted from IP:', req.ip);
}
};