Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 9640d4c

Browse files
committed
Move signInWithEmailAndPassword error code logic to the correct location
1 parent 6c235c8 commit 9640d4c

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/app/auth/index.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,12 @@ export module auth {
2020
resolve();
2121
})
2222
.catch(err => {
23-
let code = 'auth/exception';
24-
let message = err.toString();
25-
if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidCredentialsException')) {
26-
code = 'auth/wrong-password';
27-
} else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
28-
code = 'auth/user-not-found';
29-
} else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
30-
code = 'auth/invalid-email'
31-
}
3223
// Note that auth/user-disabled cannot be identified here because FirebaseAuthInvalidUserException is thrown for both
3324
// auth/user-disabled and auth/user-not-found
34-
reject({
35-
code: code,
36-
message: message,
37-
});
25+
reject(
26+
// code: "",
27+
message: err
28+
);
3829
});
3930
});
4031
}
@@ -57,9 +48,23 @@ export module auth {
5748
user: user,
5849
});
5950
}, (err => {
51+
{
52+
let code = 'auth/exception';
53+
let message = err.toString();
54+
// Identify code for android. Note that the IOS implementation doesn't return a code.
55+
if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidCredentialsException')) {
56+
code = 'auth/wrong-password';
57+
} else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
58+
code = 'auth/user-not-found';
59+
// Note that Android returns one exception for both user not found and invalid email whereas
60+
// the web api returns seperate codes. Therefore the conditional below can never be satisfied
61+
// for android.
62+
// } else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
63+
// code = 'auth/invalid-email'
64+
}
6065
reject({
61-
// code: "",
62-
message: err
66+
code: code,
67+
message: message,
6368
});
6469
}));
6570
});

0 commit comments

Comments
 (0)