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;
|
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',
|
app.post('/login/begin',
|
||||||
(_args) => beginRatelimiter.middleware(),
|
(_args) => requireAuth({ noAuthOnly: true }),
|
||||||
requireAuth({ noAuthOnly: true }),
|
|
||||||
async (req: Request, res: Response) => {
|
async (req: Request, res: Response) => {
|
||||||
if (typeof await isAuthenticated(req) == 'string') return res.status(403).send({ error: 'You are already authenticated' });
|
if (typeof await isAuthenticated(req) == 'string') return res.status(403).send({ error: 'You are already authenticated' });
|
||||||
const body = req.body as BeginReqBody;
|
const body = req.body as BeginReqBody;
|
||||||
|
@ -40,8 +36,7 @@ app.post('/login/begin',
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/login/complete',
|
app.post('/login/complete',
|
||||||
(_args) => completeRatelimiter.middleware(),
|
(_args) => requireAuth({ noAuthOnly: true }),
|
||||||
requireAuth({ noAuthOnly: true }),
|
|
||||||
async (req: Request, res: Response) => {
|
async (req: Request, res: Response) => {
|
||||||
const body = req.body as CompleteReqBody;
|
const body = req.body as CompleteReqBody;
|
||||||
if ((!body.user || typeof body.user != 'string') ||
|
if ((!body.user || typeof body.user != 'string') ||
|
||||||
|
|
Loading…
Reference in a new issue