π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Specific
Manav Rathi45b490cb43b8
diff --git a/web/packages/accounts/pages/change-email.tsx b/web/packages/accounts/pages/change-email.tsxindex 4747e07aea..4d4781aaa3 100644--- a/web/packages/accounts/pages/change-email.tsx+++ b/web/packages/accounts/pages/change-email.tsx@@ -18,6 +18,7 @@ import * as Yup from "yup";import { appHomeRoute } from "../services/redirect";import { changeEmail, sendOTT } from "../services/user";import type { PageProps } from "../types/page";+import { isHTTPErrorWithStatus } from "@/base/http";const Page: React.FC<PageProps> = () => {const router = useRouter();@@ -71,7 +72,12 @@ const ChangeEmailForm: React.FC = () => {// }, 250);} catch (e) {log.error(e);- setFieldError("email", t("email_already_taken"));+ setFieldError(+ "email",+ isHTTPErrorWithStatus(e, 403)+ ? t("email_already_taken")+ : t("generic_error"),+ );}setLoading(false);};diff --git a/web/packages/base/http.ts b/web/packages/base/http.tsindex 081ecaf5c1..0b9850ce4e 100644--- a/web/packages/base/http.ts+++ b/web/packages/base/http.ts@@ -103,6 +103,12 @@ export const ensureOk = (res: Response) => {if (!res.ok) throw new HTTPError(res);};+/**+ * Return true if this is a HTTP error with the given {@link httpStatus}.+ */+export const isHTTPErrorWithStatus = (e: unknown, httpStatus: number) =>+ e instanceof HTTPError && e.res.status == httpStatus;+/*** Return true if this is a HTTP "client" error.*