update distinct id for service tokens

This commit is contained in:
Maidul Islam
2024-05-20 19:50:52 -04:00
parent fa3f957738
commit 44e37fd531
+2 -4
View File
@@ -10,12 +10,10 @@ const getDistinctRequestActorId = (req: FastifyRequest) => {
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 `${req.auth.identityId}-machine-identity-`;
} }
if (req?.auth?.actor === ActorType.SERVICE) { if (req?.auth?.actor === ActorType.SERVICE) {
return ( return `${req.auth.serviceToken.id}-service-token`; // when user gets removed from system
`${req.auth.serviceToken.createdByEmail}-service-token` || `service-token-null-creator-${req.auth.serviceTokenId}`
); // when user gets removed from system
} }
return req.realIp; return req.realIp;
}; };