netlify / gotrue

An SWT based API for managing users and issuing SWT tokens.
https://www.gotrueapi.org
MIT License
3.84k stars 285 forks source link

Fix: external providers with multiple emails #243

Closed erezrokah closed 4 years ago

erezrokah commented 4 years ago

Fixes https://github.com/netlify/gotrue/issues/242 Related to https://github.com/netlify/netlify-cms/issues/3587

First attempt as I don't have a lot of go experience.

Instead of looking up the user just by a single email, iterate over all provider emails. When signups are enabled the primary email is preferred for registering new users.

Added more tests for GitHub, GitLab and Bitbucket (the last one required exposing the auth+api endpoints to be configured).

Would be happy to get some feedback and also planning on adding tests for processInvite (are there existing ones I didn't find?)

Update:

erquhart commented 4 years ago

@erezrokah is this good to rebase and merge?

erezrokah commented 4 years ago

@erquhart, rebased and ready to merge.

erquhart commented 4 years ago

It looks like the pattern on other PR's is someone else approves but the opener merges.