Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor: simplify token retrieval by using findById method

Piyush Gupta4091dc53a570
diff --git a/backend/src/services/identity-token-auth/identity-token-auth-service.ts b/backend/src/services/identity-token-auth/identity-token-auth-service.ts
index 8c2c90711c..1ece312ea6 100644
--- a/backend/src/services/identity-token-auth/identity-token-auth-service.ts
+++ b/backend/src/services/identity-token-auth/identity-token-auth-service.ts
@@ -535,10 +535,7 @@ export const identityTokenAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
- const token = await identityAccessTokenDAL.findOne({
- [`${TableName.IdentityAccessToken}.id` as "id"]: tokenId,
- [`${TableName.IdentityAccessToken}.authMethod` as "authMethod"]: IdentityAuthMethod.TOKEN_AUTH
- });
+ const token = await identityAccessTokenDAL.findById(tokenId);
if (!token) throw new NotFoundError({ message: `Token with ID ${tokenId} not found` });