1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-21 14:19:44 +02:00

feat: Modify logger to log to file that supports fail2ban (#284)

This commit is contained in:
Steven Correia 2022-08-22 18:42:56 -04:00 committed by GitHub
parent 21ef850913
commit 6429e22d59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 427 additions and 7844 deletions

View file

@ -1,6 +1,8 @@
const bcrypt = require('bcrypt');
const validator = require('validator');
const { getRemoteAddress } = require('../../../utils/remoteAddress');
const Errors = {
INVALID_EMAIL_OR_USERNAME: {
invalidEmailOrUsername: 'Invalid email or username',
@ -41,10 +43,16 @@ module.exports = {
const user = await sails.helpers.users.getOneByEmailOrUsername(inputs.emailOrUsername);
if (!user) {
sails.log.warn(
`Invalid email or username: "${inputs.emailOrUsername}"! (IP: ${getRemoteAddress(
this.req,
)})`,
);
throw Errors.INVALID_EMAIL_OR_USERNAME;
}
if (!bcrypt.compareSync(inputs.password, user.password)) {
sails.log.warn(`Invalid password! (IP: ${getRemoteAddress(this.req)})`);
throw Errors.INVALID_PASSWORD;
}