Refactor logging implementation and enhance authentication logging
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user