mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-30 00:12:56 +00:00
merge from master and change error codes
This commit is contained in:
@@ -201,7 +201,7 @@ const errorIndex = (props)=>{
|
||||
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 failed to provide correct credentials to access the page too many times, and you have run out of attempts.
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -26,7 +26,7 @@
|
||||
"express": "^4.19.2",
|
||||
"express-async-handler": "^1.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",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jwt-simple": "^0.5.6",
|
||||
|
||||
@@ -9,7 +9,7 @@ const rateLimit = require('express-rate-limit');
|
||||
const loginLimiter = rateLimit({
|
||||
timeWindow : 24 * 60 * 60 * 1000, // 24 hours window
|
||||
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
|
||||
@@ -23,7 +23,7 @@ const mw = {
|
||||
if (!req.get('authorization')) {
|
||||
return res
|
||||
.set('WWW-Authenticate', 'Basic realm="Authorization Required"')
|
||||
.status(401)
|
||||
.status(51)
|
||||
.send('Authorization Required');
|
||||
}
|
||||
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) {
|
||||
return next();
|
||||
}
|
||||
throw { HBErrorCode: '403', code: 401, message: 'Access denied' };
|
||||
throw { HBErrorCode: '53', code: 401, message: 'Access denied' };
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user