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

User linking #27

Merged
merged 5 commits into from
Sep 27, 2020
Merged

User linking #27

merged 5 commits into from
Sep 27, 2020

Conversation

gustavohenke
Copy link
Owner

Closes #26.

Builds on top of #25.

@@ -43,12 +43,9 @@ export class MockAuth implements firebase.auth.Auth {
return this.signIn(user, { isNewUser: true });
}

fetchProvidersForEmail(email: string): Promise<any> {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely a relic from Firebase v4 or something.

@coveralls
Copy link

coveralls commented Jun 30, 2020

Coverage Status

Coverage increased (+0.7%) to 90.861% when pulling 7537634 on linking into ecb462a on master.

@wSedlacek
Copy link
Collaborator

I'll give this a review on Friday. I'm traveling right now 😅

I look forward to trying it out when I'm back.

@gustavohenke
Copy link
Owner Author

I'm traveling right now

Bold! 😷

Copy link
Collaborator

@wSedlacek wSedlacek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't noticed any logical errors, I am a little bit wary of the optional chaining after a function call but I will leave it up to you if it's something that is worth refactoring findByEmail for.

auth/auth.ts Outdated
fetchSignInMethodsForEmail(email: string): Promise<string[]> {
throw new Error("Method not implemented.");
const providers = this.store.findByEmail(email)?.providerData || [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having findByEmail() return undefined seems like a possible places that we could clean up.
If all other usages I see of findByEmail() we are throwing errors, maybe findByEmail() should just throw an error itself?
Does fetchSignInMethodsForEmail() in Firebase throw when you give it an invalid email?

Either way I am not a big fan of optional chaining directly after a function call.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does fetchSignInMethodsForEmail() in Firebase throw when you give it an invalid email?

It doesn't.

Either way I am not a big fan of optional chaining directly after a function call.

Can fix! 😃

Comment on lines 37 to 52
describe("#fetchSignInMethodsForEmail()", () => {
it("returns list of sign in methods", async () => {
const auth = new MockAuth(app);
await auth.createUserWithEmailAndPassword("foo@bar.com", "baz");

// sign in with a different method, to make sure things don't mix up
const provider = new firebase.auth.FacebookAuthProvider();
auth.mockSocialSignIn(provider).respondWithUser("John", "john@doe.com");
auth.signInWithPopup(provider);

return expect(auth.fetchSignInMethodsForEmail("foo@bar.com")).resolves.toEqual([
firebase.auth.EmailAuthProvider.PROVIDER_ID,
]);
});
});

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add in test for cases where the email has not been configured?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup done

Base automatically changed from social-refactor to master September 27, 2020 10:49
@gustavohenke gustavohenke merged commit 4bac607 into master Sep 27, 2020
@gustavohenke gustavohenke deleted the linking branch September 27, 2020 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User linking
3 participants