Skip to content

Commit

Permalink
Made error case for email in use display correctly in front end (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phantom0110 authored Feb 20, 2024
1 parent 00917a9 commit 1dc43e9
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions client/src/components/Auth/AuthenticationResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 1dc43e9

Please sign in to comment.