mirror of
https://github.com/Foltik/Shimapan
synced 2024-12-02 10:40:14 -05:00
Fix rate limit error and remove log
This commit is contained in:
parent
bbfb1c4e35
commit
b5147c13ca
@ -37,7 +37,7 @@ const registerParams = [
|
|||||||
{name: 'invite', type: 'string'}];
|
{name: 'invite', type: 'string'}];
|
||||||
|
|
||||||
router.post('/register',
|
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),
|
verifyBody(registerParams),
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
const username = canonicalize(req.body.displayname);
|
const username = canonicalize(req.body.displayname);
|
||||||
@ -81,18 +81,15 @@ const loginParams = [
|
|||||||
{name: 'password', type: 'string'}];
|
{name: 'password', type: 'string'}];
|
||||||
|
|
||||||
router.post('/login',
|
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),
|
verifyBody(loginParams),
|
||||||
async (req, res, next) => {
|
async (req, res, next) => {
|
||||||
req.body.username = canonicalize(req.body.displayname);
|
req.body.username = canonicalize(req.body.displayname);
|
||||||
|
|
||||||
// Authenticate
|
// Authenticate
|
||||||
const user = await passportAuthenticate(req, res, next);
|
const user = await passportAuthenticate(req, res, next);
|
||||||
if (!user) {
|
if (!user)
|
||||||
// Log failure
|
|
||||||
await fs.appendFile('auth.log', `${new Date().toISOString()} login ${req.ip}\n`);
|
|
||||||
return res.status(401).json({'message': 'Unauthorized.'});
|
return res.status(401).json({'message': 'Unauthorized.'});
|
||||||
}
|
|
||||||
|
|
||||||
// Create session
|
// Create session
|
||||||
await passportLogin(user, req);
|
await passportLogin(user, req);
|
||||||
|
Loading…
Reference in New Issue
Block a user