count for null actor

This commit is contained in:
Maidul Islam
2024-05-20 19:26:03 -04:00
parent 224b26ced6
commit fa3f957738
+3 -3
View File
@@ -6,13 +6,13 @@ import { getConfig } from "@app/lib/config/env";
import { ActorType } from "@app/services/auth/auth-type"; import { ActorType } from "@app/services/auth/auth-type";
const getDistinctRequestActorId = (req: FastifyRequest) => { const getDistinctRequestActorId = (req: FastifyRequest) => {
if (req.auth.actor === ActorType.USER) { if (req?.auth?.actor === ActorType.USER) {
return req.auth.user.username; return req.auth.user.username;
} }
if (req.auth.actor === ActorType.IDENTITY) { if (req?.auth?.actor === ActorType.IDENTITY) {
return `identity-${req.auth.identityId}`; return `identity-${req.auth.identityId}`;
} }
if (req.auth.actor === ActorType.SERVICE) { if (req?.auth?.actor === ActorType.SERVICE) {
return ( return (
`${req.auth.serviceToken.createdByEmail}-service-token` || `service-token-null-creator-${req.auth.serviceTokenId}` `${req.auth.serviceToken.createdByEmail}-service-token` || `service-token-null-creator-${req.auth.serviceTokenId}`
); // when user gets removed from system ); // when user gets removed from system