Skip to content

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

Remove TokenType.TOKEN_EMAIL_CONFIRMATION

Thiago Araujo da Silvab5027946a583
diff --git a/backend/src/services/auth-token/auth-token-service.ts b/backend/src/services/auth-token/auth-token-service.ts
index aa91bd8327..4271175383 100644
--- a/backend/src/services/auth-token/auth-token-service.ts
+++ b/backend/src/services/auth-token/auth-token-service.ts
@@ -31,23 +31,17 @@ type TAuthTokenServiceFactoryDep = {
export type TAuthTokenServiceFactory = ReturnType<typeof tokenServiceFactory>;
-const generateSixDigitToken = (): string => crypto.randomInt(0, 1_000_000).toString().padStart(6, "0");
+const generateSixDigitToken = (): string => String(crypto.randomInt(10 ** 5, 10 ** 6 - 1));
const generateRandomHex = (size: number): string => crypto.randomBytes(size).toString("hex");
const computeHash = (key: string, pepper: string): string =>
crypto.nativeCrypto.createHmac("sha256", pepper).update(key).digest("hex");
-const getTokenConfig = (tokenType: TokenType) => {
+export const getTokenConfig = (tokenType: TokenType) => {
// generate random token based on specified token use-case
// type [type]
switch (tokenType) {
- case TokenType.TOKEN_EMAIL_CONFIRMATION: {
- const token = generateSixDigitToken();
- const expiresAt = new Date(new Date().getTime() + 86400000);
- const triesLeft = 3;
- return { token, expiresAt, triesLeft };
- }
case TokenType.TOKEN_EMAIL_VERIFICATION: {
const token = generateSixDigitToken();
const triesLeft = 3;
diff --git a/backend/src/services/auth-token/auth-token-types.ts b/backend/src/services/auth-token/auth-token-types.ts
index 6f493a7cbf..23ef0f3d16 100644
--- a/backend/src/services/auth-token/auth-token-types.ts
+++ b/backend/src/services/auth-token/auth-token-types.ts
@@ -1,7 +1,6 @@
import { ProjectMembershipRole } from "@app/db/schemas";
export enum TokenType {
- TOKEN_EMAIL_CONFIRMATION = "emailConfirmation",
TOKEN_EMAIL_VERIFICATION = "emailVerification", // unverified -> verified
TOKEN_EMAIL_CHANGE_OTP = "emailChangeOtp",
TOKEN_EMAIL_CHANGE_CURRENT_OTP = "emailChangeCurrentOtp",
diff --git a/backend/src/services/auth/auth-signup-service.ts b/backend/src/services/auth/auth-signup-service.ts
index 3325cde6a0..63e2687b19 100644
--- a/backend/src/services/auth/auth-signup-service.ts
+++ b/backend/src/services/auth/auth-signup-service.ts
@@ -113,8 +113,6 @@ export const authSignupServiceFactory = ({
throw new Error("Invalid or expired verification request");
}
- if (!user) throw new Error("Failed to create user");
-
const appCfg = getConfig();
const jwtToken = crypto.jwt().sign(
{