Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email in use error case #158

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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