mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-03-04 11:53:18 +00:00
fix: fix getUser in rate limit
This commit is contained in:
@@ -68,9 +68,13 @@ export default async function start() {
|
||||
}),
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: async (request: express.Request, response: express.Response) => {
|
||||
const user = await getUser(request);
|
||||
if (user && user.isAdmin) return 0;
|
||||
if (user) return config.RATE_LIMIT;
|
||||
try {
|
||||
const user = await getUser(request);
|
||||
if (user && user.isAdmin) return 0;
|
||||
if (user) return config.RATE_LIMIT;
|
||||
} catch (_) {
|
||||
// ignore: user not connected
|
||||
}
|
||||
// if not logged in, limit to half the rate
|
||||
return config.RATE_LIMIT / 2;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user