From 4d3936e05035f602bd8f6d1901fd1ce3d770b711 Mon Sep 17 00:00:00 2001 From: Konstantin Wohlwend Date: Tue, 14 Jan 2025 18:35:58 -0800 Subject: [PATCH] Fix STACK-SERVER-P0 --- .../stack/src/components-page/account-settings.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/stack/src/components-page/account-settings.tsx b/packages/stack/src/components-page/account-settings.tsx index 927baa3c1..05210819f 100644 --- a/packages/stack/src/components-page/account-settings.tsx +++ b/packages/stack/src/components-page/account-settings.tsx @@ -1,6 +1,7 @@ 'use client'; import { yupResolver } from "@hookform/resolvers/yup"; +import { KnownErrors } from "@stackframe/stack-shared"; import { getPasswordError } from '@stackframe/stack-shared/dist/helpers/password'; import { useAsyncCallback } from '@stackframe/stack-shared/dist/hooks/use-async-callback'; import { passwordSchema as schemaFieldsPasswordSchema, strictEmailSchema, yupObject, yupString } from '@stackframe/stack-shared/dist/schema-fields'; @@ -307,7 +308,15 @@ function EmailsSection() { }] : []), ...(!x.usedForAuth && x.isVerified ? [{ item: t("Use for sign-in"), - onClick: async () => { await x.update({ usedForAuth: true }); }, + onClick: async () => { + try { + await x.update({ usedForAuth: true }); + } catch (e) { + if (e instanceof KnownErrors.ContactChannelAlreadyUsedForAuthBySomeoneElse) { + alert(t("This email is already used for sign-in by another user.")); + } + } + } }] : []), ...(x.usedForAuth && !isLastEmail ? [{ item: t("Stop using for sign-in"),