Skip to content

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

improvements: address feedback

Scott Wilson68066cb5fe8a
diff --git a/backend/src/services/user/user-service.ts b/backend/src/services/user/user-service.ts
index 47f8c294f4..5f6004e8a5 100644
--- a/backend/src/services/user/user-service.ts
+++ b/backend/src/services/user/user-service.ts
@@ -298,6 +298,10 @@ export const userServiceFactory = ({
const user = await userDAL.findById(userId, tx);
if (!user) throw new NotFoundError({ message: `User with ID '${userId}' not found`, name: "UpdateUserEmail" });
+ if (user.authMethods?.includes(AuthMethod.LDAP)) {
+ throw new BadRequestError({ message: "Cannot update email for LDAP users", name: "UpdateUserEmail" });
+ }
+
const hasScimRestriction = await checkUserScimRestriction(userId, tx);
if (hasScimRestriction) {
throw new BadRequestError({
diff --git a/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx b/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx
index 3bc6d71636..710cdcee00 100644
--- a/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx
+++ b/frontend/src/pages/user/PersonalSettingsPage/components/ChangeEmailSection/ChangeEmailSection.tsx
@@ -122,7 +122,14 @@ export const ChangeEmailSection = () => {
return;
}
- await verifyCurrentEmailOTP({ otpCode: typedOTP });
+ try {
+ await verifyCurrentEmailOTP({ otpCode: typedOTP });
+ } catch {
+ // The OTP token is single-use (triesLeft = 1) — any failure consumes it server-side,
+ // so the user must restart the flow to request a fresh code.
+ resetFlow();
+ return;
+ }
setTypedOTP("");
setOtpStep("newEmail");
@@ -142,7 +149,12 @@ export const ChangeEmailSection = () => {
return;
}
- await updateUserEmail({ newEmail: pendingEmail, otpCode: typedOTP });
+ try {
+ await updateUserEmail({ newEmail: pendingEmail, otpCode: typedOTP });
+ } catch {
+ resetFlow();
+ return;
+ }
createNotification({
text: "Email updated successfully. You will be redirected to login.",