From 1dc43e97482e57c79cbddfc63ce78fbbf831bfcd Mon Sep 17 00:00:00 2001 From: Mohammed Ali <146048575+Phantom0110@users.noreply.github.com> Date: Tue, 20 Feb 2024 18:28:06 -0500 Subject: [PATCH] Made error case for email in use display correctly in front end (#158) --- .../Auth/AuthenticationResponse.tsx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/client/src/components/Auth/AuthenticationResponse.tsx b/client/src/components/Auth/AuthenticationResponse.tsx index cb74702f5..c2955772b 100644 --- a/client/src/components/Auth/AuthenticationResponse.tsx +++ b/client/src/components/Auth/AuthenticationResponse.tsx @@ -27,23 +27,22 @@ export const inValidEmailResponse = new CustomError("Invalid Email", "Please pro //Function that decodes the error code const decodeFirebaseError = (error: FirebaseError) => { - if(error.code === "auth/missing-email" || error.code === "auth/invalid-email") { - return "Please provide a valid email address"; + switch (error.code) { + case "auth/missing-email" || "auth/invalid-email": + return "Please provide a valid email address"; + case "auth/weak-password": + return "Password must be 6 characters or more"; + case "auth/missing-password": + return "Please provide a password"; + case "auth/invalid-credential": + return "The password or email is incorrect"; + case "auth/too-many-requests": + return "Too many requests, please try again later"; + case "auth/email-already-in-use": + return "Email already in use"; + default: + return "Unknown error"; } - - if(error.code === "auth/weak-password") { - return "Password must be 6 characters or more"; - } - - if(error.code === "auth/missing-password") { - return "Please provide a password"; - } - - if(error.code === "auth/invalid-credential") { - return "The password or email is incorrect"; - } - - return "Unknown error" } const decodeCustomError = (error: CustomError) => {