Skip to content

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

Add login email lowercasing to backend

Tuan Dang4e1abc6eba5b
diff --git a/backend/src/routes/v1/auth.ts b/backend/src/routes/v1/auth.ts
index b633f82ea6..f373567f2c 100644
--- a/backend/src/routes/v1/auth.ts
+++ b/backend/src/routes/v1/auth.ts
@@ -11,7 +11,7 @@ router.post("/token", validateRequest, authController.getNewToken);
router.post( // TODO endpoint: deprecate (moved to api/v3/auth/login1)
"/login1",
authLimiter,
- body("email").exists().trim().notEmpty(),
+ body("email").exists().trim().notEmpty().toLowerCase(),
body("clientPublicKey").exists().trim().notEmpty(),
validateRequest,
authController.login1
@@ -20,7 +20,7 @@ router.post( // TODO endpoint: deprecate (moved to api/v3/auth/login1)
router.post( // TODO endpoint: deprecate (moved to api/v3/auth/login2)
"/login2",
authLimiter,
- body("email").exists().trim().notEmpty(),
+ body("email").exists().trim().notEmpty().toLowerCase(),
body("clientProof").exists().trim().notEmpty(),
validateRequest,
authController.login2
diff --git a/backend/src/routes/v2/auth.ts b/backend/src/routes/v2/auth.ts
index bf348c2792..e2d45f4525 100644
--- a/backend/src/routes/v2/auth.ts
+++ b/backend/src/routes/v2/auth.ts
@@ -8,7 +8,7 @@ import { authLimiter } from "../../helpers/rateLimiter";
router.post( // TODO: deprecate (moved to api/v3/auth/login1)
"/login1",
authLimiter,
- body("email").isString().trim().notEmpty(),
+ body("email").isString().trim().notEmpty().toLowerCase(),
body("clientPublicKey").isString().trim().notEmpty(),
validateRequest,
authController.login1
@@ -17,7 +17,7 @@ router.post( // TODO: deprecate (moved to api/v3/auth/login1)
router.post( // TODO: deprecate (moved to api/v3/auth/login1)
"/login2",
authLimiter,
- body("email").isString().trim().notEmpty(),
+ body("email").isString().trim().notEmpty().toLowerCase(),
body("clientProof").isString().trim().notEmpty(),
validateRequest,
authController.login2
diff --git a/backend/src/routes/v3/auth.ts b/backend/src/routes/v3/auth.ts
index 12afb51136..ba6f303358 100644
--- a/backend/src/routes/v3/auth.ts
+++ b/backend/src/routes/v3/auth.ts
@@ -9,7 +9,7 @@ const router = express.Router();
router.post(
"/login1",
authLimiter,
- body("email").isString().trim(),
+ body("email").isString().trim().toLowerCase(),
body("providerAuthToken").isString().trim().optional({nullable: true}),
body("clientPublicKey").isString().trim().notEmpty(),
validateRequest,
@@ -19,7 +19,7 @@ router.post(
router.post(
"/login2",
authLimiter,
- body("email").isString().trim(),
+ body("email").isString().trim().toLowerCase(),
body("providerAuthToken").isString().trim().optional({nullable: true}),
body("clientProof").isString().trim().notEmpty(),
validateRequest,
diff --git a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx
index 08fc86fd93..7bab7414e6 100644
--- a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx
+++ b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx
@@ -45,15 +45,13 @@ export const InitialStep = ({
return;
}
- const sanitizedEmail = email.toLowerCase();
-
setIsLoading(true);
if (queryParams && queryParams.get("callback_port")) {
const callbackPort = queryParams.get("callback_port")
// attemptCliLogin
const isCliLoginSuccessful = await attemptCliLogin({
- email: sanitizedEmail,
+ email: email.toLowerCase(),
password,
})
@@ -80,7 +78,7 @@ export const InitialStep = ({
}
} else {
const isLoginSuccessful = await attemptLogin({
- email: sanitizedEmail,
+ email: email.toLowerCase(),
password,
});
if (isLoginSuccessful && isLoginSuccessful.success) {