From abbed321c46e4cf27c642f2489db9ebab3cc76eb Mon Sep 17 00:00:00 2001 From: Estifanos Gashawtena <88879001+Estifanos12@users.noreply.github.com> Date: Sat, 23 Mar 2024 13:07:15 +0300 Subject: [PATCH] impr(login page): better error message (Estifanos12) (#5244) * fix:create user email already exists message * Update account-controller.ts * Update account-controller.ts * Update account-controller.ts * Update account-controller.ts * Update account-controller.ts * Update account-controller.ts --- frontend/src/ts/controllers/account-controller.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/ts/controllers/account-controller.ts b/frontend/src/ts/controllers/account-controller.ts index afc506b307fe..b9971a7c7169 100644 --- a/frontend/src/ts/controllers/account-controller.ts +++ b/frontend/src/ts/controllers/account-controller.ts @@ -591,7 +591,17 @@ async function signUp(): Promise { } Notifications.add("Account created", 1); } catch (e) { - const message = Misc.createErrorMessage(e, "Failed to create account"); + let message = Misc.createErrorMessage(e, "Failed to create account"); + + if (e instanceof Error) { + if ("code" in e && e.code === "auth/email-already-in-use") { + message = Misc.createErrorMessage( + { message: "Email already in use" }, + "Failed to create account" + ); + } + } + Notifications.add(message, -1); LoginPage.hidePreloader(); LoginPage.enableInputs();