fix middlewares
This commit is contained in:
parent
c973278b5a
commit
14c30beb49
1 changed files with 2 additions and 7 deletions
|
@ -24,12 +24,8 @@ class CompleteReqBody {
|
|||
code: string;
|
||||
}
|
||||
|
||||
const beginRatelimiter = new RateLimiter('/login/begin', { limit: 10, timeframe: 300 });
|
||||
const completeRatelimiter = new RateLimiter('/login/complete', { limit: 5, timeframe: 30 });
|
||||
|
||||
app.post('/login/begin',
|
||||
(_args) => beginRatelimiter.middleware(),
|
||||
requireAuth({ noAuthOnly: true }),
|
||||
(_args) => requireAuth({ noAuthOnly: true }),
|
||||
async (req: Request, res: Response) => {
|
||||
if (typeof await isAuthenticated(req) == 'string') return res.status(403).send({ error: 'You are already authenticated' });
|
||||
const body = req.body as BeginReqBody;
|
||||
|
@ -40,8 +36,7 @@ app.post('/login/begin',
|
|||
});
|
||||
|
||||
app.post('/login/complete',
|
||||
(_args) => completeRatelimiter.middleware(),
|
||||
requireAuth({ noAuthOnly: true }),
|
||||
(_args) => requireAuth({ noAuthOnly: true }),
|
||||
async (req: Request, res: Response) => {
|
||||
const body = req.body as CompleteReqBody;
|
||||
if ((!body.user || typeof body.user != 'string') ||
|
||||
|
|
Loading…
Reference in a new issue