Skip to content

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

feat: moved check to top

=3e49a29663c0
diff --git a/backend/src/services/account-recovery/account-recovery-service.ts b/backend/src/services/account-recovery/account-recovery-service.ts
index 590ceb39a5..296adefda8 100644
--- a/backend/src/services/account-recovery/account-recovery-service.ts
+++ b/backend/src/services/account-recovery/account-recovery-service.ts
@@ -91,16 +91,14 @@ export const accountRecoveryServiceFactory = ({
// akhilmhdh: case sensitive email resolution
const user = users?.length > 1 ? users.find((el) => el.username === email) : users?.[0];
if (!user) throw new BadRequestError({ message: "Failed to find user data" });
-
- const userEnc = await userDAL.findUserEncKeyByUserId(user.id);
-
- if (!userEnc) throw new BadRequestError({ message: "Failed to find user encryption data" });
-
// ignore as user is not found to avoid an outside entity to identify infisical registered accounts
if (!user || (user && !user.isAccepted)) {
throw new Error("Failed email verification for pass reset");
}
+ const userEnc = await userDAL.findUserEncKeyByUserId(user.id);
+ if (!userEnc) throw new BadRequestError({ message: "Failed to find user encryption data" });
+
await tokenService.validateTokenForUser({
type: TokenType.TOKEN_EMAIL_PASSWORD_RESET,
userId: user.id,