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

Commit 33699a3

Browse files
Merge pull request #1064 from BrianChapman/feat_sign_in_with_username_and_password
Make signInWithEmailAndPassword resolve and reject consistent with web api
2 parents 312ef8f + a77b82c commit 33699a3

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/app/auth/index.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,30 @@ export module auth {
3939
}).then((user: User) => {
4040
this.currentUser = user;
4141
this.authStateChangedHandler && this.authStateChangedHandler(user);
42-
resolve();
42+
resolve({
43+
additionalUserInfo: user.additionalUserInfo,
44+
credential: null,
45+
operationType: "SignIn",
46+
user: user,
47+
});
4348
}, (err => {
49+
{
50+
let code = 'auth/exception';
51+
let message = err.toString();
52+
// Identify code for android. Note that the IOS implementation doesn't return a code.
53+
if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidCredentialsException')) {
54+
code = 'auth/wrong-password';
55+
} else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
56+
code = 'auth/user-not-found';
57+
// Note that Android returns one exception for both user not found and invalid email whereas
58+
// the web api returns seperate codes. Therefore the conditional below can never be satisfied
59+
// for android.
60+
// } else if (message.includes('com.google.firebase.auth.FirebaseAuthInvalidUserException')) {
61+
// code = 'auth/invalid-email'
62+
}
4463
reject({
45-
// code: "",
46-
message: err
64+
code: code,
65+
message: message,
4766
});
4867
}));
4968
});

0 commit comments

Comments
 (0)