Merge pull request #507 from ajnart/506-log-authentication-attempts-when-password-environment-variable-is-used

#506 Add warning on wrong password attemps
This commit is contained in:
Thomas Camlong
2022-11-21 18:10:43 +09:00
committed by GitHub

View File

@@ -1,3 +1,4 @@
import Consola from 'consola';
import { NextApiRequest, NextApiResponse } from 'next';
function Post(req: NextApiRequest, res: NextApiResponse) {
@@ -8,6 +9,12 @@ function Post(req: NextApiRequest, res: NextApiResponse) {
success: true,
});
}
// Warn that there was a wrong password attempt (date : wrong password, person's IP)
Consola.warn(
`${new Date().toLocaleString()} : Wrong password attempt, from ${
req.headers['x-forwarded-for']
}`
);
return res.status(200).json({
success: false,
});