From fa3f957738d91367936b57faadbf0d72919ef144 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Mon, 20 May 2024 19:26:03 -0400 Subject: [PATCH] count for null actor --- backend/src/server/config/rateLimiter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/server/config/rateLimiter.ts b/backend/src/server/config/rateLimiter.ts index 2221bf9f1..997ed9daf 100644 --- a/backend/src/server/config/rateLimiter.ts +++ b/backend/src/server/config/rateLimiter.ts @@ -6,13 +6,13 @@ import { getConfig } from "@app/lib/config/env"; import { ActorType } from "@app/services/auth/auth-type"; const getDistinctRequestActorId = (req: FastifyRequest) => { - if (req.auth.actor === ActorType.USER) { + if (req?.auth?.actor === ActorType.USER) { return req.auth.user.username; } - if (req.auth.actor === ActorType.IDENTITY) { + if (req?.auth?.actor === ActorType.IDENTITY) { return `identity-${req.auth.identityId}`; } - if (req.auth.actor === ActorType.SERVICE) { + if (req?.auth?.actor === ActorType.SERVICE) { return ( `${req.auth.serviceToken.createdByEmail}-service-token` || `service-token-null-creator-${req.auth.serviceTokenId}` ); // when user gets removed from system