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

Commit 6c235c8

Browse files
committed
Add error code to signInWithEmailAndPassword
1 parent 00f44df commit 6c235c8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/app/auth/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,20 @@ 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+
}
32+
// Note that auth/user-disabled cannot be identified here because FirebaseAuthInvalidUserException is thrown for both
33+
// auth/user-disabled and auth/user-not-found
2334
reject({
24-
// code: "",
25-
message: err
35+
code: code,
36+
message: message,
2637
});
2738
});
2839
});

0 commit comments

Comments
 (0)