feat: resolved generate srp failing for user enc v1 users

This commit is contained in:
=
2024-06-20 22:12:44 +05:30
parent 31e27ad1d7
commit 5ace8ed073
4 changed files with 52 additions and 27 deletions
@@ -9,6 +9,7 @@ import { generateSrpServerKey, srpCheckClientProof } from "@app/lib/crypto";
import { infisicalSymmetricEncypt } from "@app/lib/crypto/encryption";
import { getUserPrivateKey } from "@app/lib/crypto/srp";
import { BadRequestError, DatabaseError, UnauthorizedError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { getServerCfg } from "@app/services/super-admin/super-admin-service";
import { TTokenDALFactory } from "../auth-token/auth-token-dal";
@@ -258,7 +259,10 @@ export const authLoginServiceFactory = ({
});
// from password decrypt the private key
if (password) {
const privateKey = await getUserPrivateKey(password, userEnc);
const privateKey = await getUserPrivateKey(password, userEnc).catch((err) => {
logger.error(err, `private key generation failed for user id - ${user.id} and email -${user.email}`);
return "";
});
const hashedPassword = await bcrypt.hash(password, cfg.BCRYPT_SALT_ROUND);
const { iv, tag, ciphertext, encoding } = infisicalSymmetricEncypt(privateKey);
await userDAL.updateUserEncryptionByUserId(userEnc.userId, {