Allow automatically linking existing users to their Omniauth providers accounts if email addresses matches
Summary
Stemming from discussion in #390404 (comment 1298934252). If an existing user tries to sign in using Omniauth providers account that have the same email address as their GitLab account, sign-in will fail and redirect to a 422 error page indicating "Email has already been taken".
Proposal
Allow the user to login in the situation above and automatically link their Omniauth account to their GitLab account.
Potential solution
Currently:
- For existing user, he can log in via other OmniAuth providers (SSO options) by linking those accounts by going to Profile settings: https://docs.gitlab.com/ee/integration/omniauth.html#enable-omniauth-for-an-existing-user
- There is already functionality set up for automatically linking existing users to their OpenID Connect provider accounts if the email addresses matches: https://docs.gitlab.com/ee/integration/omniauth.html#link-existing-users-to-omniauth-users, may just need to reconfigure gitlab.com through here: https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/gitlab.yml.example#L1037
Edited by Roy Liu