0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-14 04:12:43 +00:00

merge from master and change error codes

This commit is contained in:
Víctor Losada Hernández
2024-09-16 22:34:28 +02:00
parent a0d043439c
commit 0d2878a7e7
3 changed files with 5 additions and 5 deletions

View File

@@ -201,7 +201,7 @@ const errorIndex = (props)=>{
as so at our subreddit or discord you will find in the home page. as so at our subreddit or discord you will find in the home page.
`, `,
'53' : dedent` '54' : dedent`
## You have runned out of attempts ## You have runned out of attempts
You have failed to provide correct credentials to access the page too many times, and you have run out of attempts. You have failed to provide correct credentials to access the page too many times, and you have run out of attempts.

2
package-lock.json generated
View File

@@ -26,7 +26,7 @@
"express": "^4.19.2", "express": "^4.19.2",
"express-async-handler": "^1.2.0", "express-async-handler": "^1.2.0",
"express-rate-limit": "^7.2.0", "express-rate-limit": "^7.2.0",
"express-static-gzip": "2.1.7", "express-static-gzip": "2.1.8",
"fs-extra": "11.2.0", "fs-extra": "11.2.0",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"jwt-simple": "^0.5.6", "jwt-simple": "^0.5.6",

View File

@@ -9,7 +9,7 @@ const rateLimit = require('express-rate-limit');
const loginLimiter = rateLimit({ const loginLimiter = rateLimit({
timeWindow : 24 * 60 * 60 * 1000, // 24 hours window timeWindow : 24 * 60 * 60 * 1000, // 24 hours window
max : 10, // limit each IP to 10 requests per timeWindow max : 10, // limit each IP to 10 requests per timeWindow
handler : ()=>{throw { HBErrorCode: '470', code: 470, message: 'Too many failed login attempts, try again later' }; } handler : ()=>{throw { HBErrorCode: '54', code: 470, message: 'Too many failed login attempts, try again later' }; }
}); });
//Local version username and password //Local version username and password
@@ -23,7 +23,7 @@ const mw = {
if (!req.get('authorization')) { if (!req.get('authorization')) {
return res return res
.set('WWW-Authenticate', 'Basic realm="Authorization Required"') .set('WWW-Authenticate', 'Basic realm="Authorization Required"')
.status(401) .status(51)
.send('Authorization Required'); .send('Authorization Required');
} }
const [username, password] = Buffer.from(req.get('authorization').split(' ').pop(), 'base64') const [username, password] = Buffer.from(req.get('authorization').split(' ').pop(), 'base64')
@@ -32,7 +32,7 @@ const mw = {
if (process.env.ADMIN_USER === username && process.env.ADMIN_PASS === password) { if (process.env.ADMIN_USER === username && process.env.ADMIN_PASS === password) {
return next(); return next();
} }
throw { HBErrorCode: '403', code: 401, message: 'Access denied' }; throw { HBErrorCode: '53', code: 401, message: 'Access denied' };
} }
] ]
}; };