mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-31 19:59:31 -05:00
feat(login): add request ip to the failed request log (#714)
This commit is contained in:
@@ -22,6 +22,7 @@ import { getAppVersion } from './utils/appVersion';
|
||||
import SlackAgent from './lib/notifications/agents/slack';
|
||||
import PushoverAgent from './lib/notifications/agents/pushover';
|
||||
import WebhookAgent from './lib/notifications/agents/webhook';
|
||||
import { getClientIp } from '@supercharge/request-ip';
|
||||
|
||||
const API_SPEC_PATH = path.join(__dirname, '../overseerr-api.yml');
|
||||
|
||||
@@ -62,6 +63,21 @@ app
|
||||
server.use(cookieParser());
|
||||
server.use(bodyParser.json());
|
||||
server.use(bodyParser.urlencoded({ extended: true }));
|
||||
server.use((req, res, next) => {
|
||||
try {
|
||||
const descriptor = Object.getOwnPropertyDescriptor(req, 'ip');
|
||||
if (descriptor?.writable === true) {
|
||||
req.ip = getClientIp(req) ?? '';
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error('Failed to attach the ip to the request', {
|
||||
label: 'Middleware',
|
||||
message: e.message,
|
||||
});
|
||||
} finally {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
// Setup sessions
|
||||
const sessionRespository = getRepository(Session);
|
||||
|
||||
@@ -151,6 +151,7 @@ authRoutes.post('/local', async (req, res, next) => {
|
||||
logger.info('Failed login attempt from user with incorrect credentials', {
|
||||
label: 'Auth',
|
||||
account: {
|
||||
ip: req.ip,
|
||||
email: body.email,
|
||||
password: '__REDACTED__',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user