Skip to content

GitHub Login: If a user changes their primary email on GitHub Coder creates a new account for them instead of updating the email on existing account #10972

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

Closed
matifali opened this issue Dec 1, 2023 · 13 comments · Fixed by #12112
Assignees
Labels
s1 Bugs that break core workflows. Only humans may set this.

Comments

@matifali
Copy link
Member

matifali commented Dec 1, 2023

I updated my primary email in GitHub, and after that, when I tried to log in to Coder using GitHub, Coder created a new username for me with username old_user_name_SOME_RANDOM_STRING with the new email address. I got locked out of my old account.
Related #10726, #4618

image

See how a new user account is created for me after changing the email. Both are GitHub accounts.

Steps to reproduce:

  1. Go to https://github.com/settings/emails and chnage your primary email
  2. Logout and login to Coder
@matifali matifali added s1 Bugs that break core workflows. Only humans may set this. bug labels Dec 1, 2023
@matifali matifali changed the title GitHub Login: If a user chnages their primary email on GitHub Coder createsa a new account for them instead of updating the email on existing account GitHub Login: If a user chnages their primary email on GitHub Coder creates a new account for them instead of updating the email on existing account Dec 1, 2023
@matifali
Copy link
Member Author

matifali commented Dec 1, 2023

cc: @kylecarbs

@kylecarbs
Copy link
Member

@sreya don't we link based on ID?

@sreya
Copy link
Collaborator

sreya commented Dec 1, 2023

Yeah we should be.

@matifali
Copy link
Member Author

matifali commented Dec 2, 2023

We should also automatically update the email and username for GitHub and OIDC accounts, as requested in #10516.

When a user configures an IdP or OIDC for the source of truth of usernames and emails, they will probably not use these fields in naming resources in the templates.

We can help by putting a warning in the docs on configuring OIDC/GitHub OAuth on not using these fields as part of resource names.

I have seen this behavior in Artifactory, where username and email always sync with the IDP.

@matifali matifali changed the title GitHub Login: If a user chnages their primary email on GitHub Coder creates a new account for them instead of updating the email on existing account GitHub Login: If a user changes their primary email on GitHub Coder creates a new account for them instead of updating the email on existing account Dec 5, 2023
@Emyrk
Copy link
Member

Emyrk commented Jan 25, 2024

I actually cannot reproduce this 🤔

@Emyrk
Copy link
Member

Emyrk commented Jan 26, 2024

@matifali can you reproduce this? I cannot and maybe it has been fixed and we can close?

@matifali
Copy link
Member Author

@Emyrk I changed my GitHub primary email to my Coder email address and I can't log in anymore as I already havy an google OIDC account. Ideal should be to merge both accounts in this case.

Screenshot_20240126-215839

If I change my primary email to some other email address Coder created. Anew account for me again.

Screenshot_20240126-220105

@Emyrk
Copy link
Member

Emyrk commented Jan 26, 2024

@Emyrk I changed my GitHub primary email to my Coder email address and I can't log in anymore as I already havy an google OIDC account. Ideal should be to merge both accounts in this case.

Yup this is actually intentional. Merging accounts can be done similar to how we do "Convert to OIDC" from password auth.

We cannot automatically merge them. We would need the user to authenticate via both oauth methods, then click merge from both sides (whatever that looks like).


So this behavior is currently intentional.

@matifali
Copy link
Member Author

@ben, @stirby can you try to reproduce this too? I can consistently reproduce.

@f0ssel
Copy link
Contributor

f0ssel commented Jan 31, 2024

Attempt to reproduce

When I change my primary github email from garrett@delfosse.dev to garrett@coder.com I get the following conflict error.

{"message":"Failed to process OAuth login.","detail":"in tx: execute transaction: update user profile: pq: duplicate key value violates unique constraint \"idx_users_email\""}

This makes sense, since I have a gmail login with garrett@coder.com already and that's a separate coder account.

When I change the primary email to delfossegarrett@gmail.com which should not have a conflict I am logged into my existing account (formerly garrett@delfosse.dev) correctly.

So I'd say I also cannot reproduce the same behavior Atif is seeing. I did not touch anything regarding my "public email" in this experiment, thought it was worth mentioning.

@stirby
Copy link
Collaborator

stirby commented Jan 31, 2024

I experienced the exact same behavior as @f0ssel, unable to reproduce the other issue.

@Emyrk
Copy link
Member

Emyrk commented Jan 31, 2024

I wonder if something is different about @matifali's account 🤔

He is able to reproduce it on his own deployment too

@matifali
Copy link
Member Author

@Emyrk and I figured out how to reproduce this. You need to delete your account once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s1 Bugs that break core workflows. Only humans may set this.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants