1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-30 14:31:42 -05:00

Fix rate limit error and remove log

This commit is contained in:
Jack Foltz 2019-01-02 17:18:07 -05:00
parent bbfb1c4e35
commit b5147c13ca
Signed by: foltik
GPG Key ID: D1F0331758D1F29A

View File

@ -37,7 +37,7 @@ const registerParams = [
{name: 'invite', type: 'string'}];
router.post('/register',
rateLimit(config.get('RateLimit.register.window'), config.get('RateLimit.register.max'), true),
rateLimit(config.get('RateLimit.register.window'), config.get('RateLimit.register.max')),
verifyBody(registerParams),
async (req, res) => {
const username = canonicalize(req.body.displayname);
@ -81,18 +81,15 @@ const loginParams = [
{name: 'password', type: 'string'}];
router.post('/login',
rateLimit(config.get('RateLimit.login.window'), config.get('RateLimit.login.max'), true),
rateLimit(config.get('RateLimit.login.window'), config.get('RateLimit.login.max')),
verifyBody(loginParams),
async (req, res, next) => {
req.body.username = canonicalize(req.body.displayname);
// Authenticate
const user = await passportAuthenticate(req, res, next);
if (!user) {
// Log failure
await fs.appendFile('auth.log', `${new Date().toISOString()} login ${req.ip}\n`);
if (!user)
return res.status(401).json({'message': 'Unauthorized.'});
}
// Create session
await passportLogin(user, req);