Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Use correct error

Manav Rathi15d77b7551ca
diff --git a/web/packages/accounts/components/Verify2FACodeForm.tsx b/web/packages/accounts/components/Verify2FACodeForm.tsx
index 3084fa4d76..0e036b64b8 100644
--- a/web/packages/accounts/components/Verify2FACodeForm.tsx
+++ b/web/packages/accounts/components/Verify2FACodeForm.tsx
@@ -1,4 +1,5 @@
import { LoadingButton } from "@/base/components/mui/LoadingButton";
+import { isHTTP401Error } from "@/base/http";
import log from "@/base/log";
import { Stack, styled, Typography } from "@mui/material";
import { useFormik } from "formik";
@@ -45,7 +46,12 @@ export const Verify2FACodeForm: React.FC<Verify2FACodeFormProps> = ({
} catch (e) {
log.error("Failed to submit 2FA code", e);
resetForm();
- setFieldError("otp", t("generic_error"));
+ setFieldError(
+ "otp",
+ isHTTP401Error(e)
+ ? t("incorrect_code")
+ : t("generic_error"),
+ );
// Workaround (toggling shouldAutoFocus) to reset the focus back
// to the first input field in case of errors.
// https://github.com/devfolioco/react-otp-input/issues/420
@@ -90,7 +96,7 @@ export const Verify2FACodeForm: React.FC<Verify2FACodeFormProps> = ({
/>
{errors.otp && (
<Typography variant="mini" sx={{ color: "critical.main" }}>
- {t("incorrect_code")}
+ {errors.otp}
</Typography>
)}
<LoadingButton