assert uid for each request

This commit is contained in:
Sha Zhou 2025-05-09 18:42:35 +08:00
parent 5674402bb1
commit 6f41539587

View File

@ -86,10 +86,10 @@ export const jinaAiMiddleware = (req: Request, res: Response, next: NextFunction
[RPC_CALL_ENVIRONMENT]: { req, res }
});
const uid = await authDto.solveUID();
if (!uid && !ctx.ip) {
throw new OperationNotAllowedError(`Missing IP information for anonymous user`);
}
const uid = await authDto.assertUID();
// if (!uid && !ctx.ip) {
// throw new OperationNotAllowedError(`Missing IP information for anonymous user`);
// }
let rateLimitPolicy
if (uid) {
const user = await authDto.assertUser();
@ -110,7 +110,7 @@ export const jinaAiMiddleware = (req: Request, res: Response, next: NextFunction
} else {
rateLimitPolicy = [
RateLimitDesc.from({
occurrence: 1,
occurrence: 0,
periodSeconds: 120
})
]