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

Cannot change email to the same value of existing auth.identities record for non-"email" providers #1060

Closed
ttskch opened this issue Mar 14, 2023 · 1 comment · Fixed by #1092
Assignees
Labels
auth bug Something isn't working released

Comments

@ttskch
Copy link

ttskch commented Mar 14, 2023

Bug report

Describe the bug

User cannot change email to the same value of existing auth.identities record for non-"email" providers.

To Reproduce

  1. Sign up with "foo@bar.com" using signUp().
  2. A record is inserted into auth.identities table with a value of "email" for the provider column and a value of "foo@bar.com" for the email column.
  3. Sign in using signInWithOAuth() with a Twitter account that has the email address "foo@bar.com" registered.
  4. A record is inserted into auth.identities table with a value of "twitter" for the provider column and a value of "foo@bar.com" for the email column.
  5. Update the email address with updateUser({email: 'newEmail@bar.com'}).
  6. The email column value for the record with a value of "email" in the provider column in the auth.identities table is changed to "newEmail@bar.com".
  7. Try to revert the email address back to "foo@bar.com" with updateUser({email: 'foo@bar.com'}).
  8. "User already registered." error occurs.

Expected behavior

If none of the records in the auth.identities table with a value of "email" for the provider column have the same email address as the one being updated, it is possible to change the email address to that value.

@ttskch ttskch added the bug Something isn't working label Mar 14, 2023
@J0 J0 transferred this issue from supabase/supabase Apr 11, 2023
@kangmingtay kangmingtay self-assigned this Apr 19, 2023
kangmingtay added a commit that referenced this issue Apr 20, 2023
…er (#1092)

## What kind of change does this PR introduce?
* Fixes #1060, #988 
* Allows one to pass in an optional `currentUser` into
`IsDuplicatedUser` to exclude the user's identities when checking for
duplicates
* This is optional because on signup / admin create user, there won't be
a current user so it's guaranteed that any identities found belongs to a
different user.

## Current behaviour
* Currently, `IsDuplicatedEmail` only accepts an `email` and an `aud`
and uses those fields to check if the `auth.identities` table has
identities with the same email. When this is used in the context of
updating a user's email (`PUT /user`), `IsDuplicatedEmail` will also
include identities that belong to the current user.

---------

Co-authored-by: Joel Lee <lee.yi.jie.joel@gmail.com>
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 2.60.9 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

uxodb pushed a commit to uxodb/auth that referenced this issue Nov 13, 2024
…er (supabase#1092)

## What kind of change does this PR introduce?
* Fixes supabase#1060, supabase#988 
* Allows one to pass in an optional `currentUser` into
`IsDuplicatedUser` to exclude the user's identities when checking for
duplicates
* This is optional because on signup / admin create user, there won't be
a current user so it's guaranteed that any identities found belongs to a
different user.

## Current behaviour
* Currently, `IsDuplicatedEmail` only accepts an `email` and an `aud`
and uses those fields to check if the `auth.identities` table has
identities with the same email. When this is used in the context of
updating a user's email (`PUT /user`), `IsDuplicatedEmail` will also
include identities that belong to the current user.

---------

Co-authored-by: Joel Lee <lee.yi.jie.joel@gmail.com>
LashaJini pushed a commit to LashaJini/auth that referenced this issue Nov 13, 2024
…er (supabase#1092)

## What kind of change does this PR introduce?
* Fixes supabase#1060, supabase#988 
* Allows one to pass in an optional `currentUser` into
`IsDuplicatedUser` to exclude the user's identities when checking for
duplicates
* This is optional because on signup / admin create user, there won't be
a current user so it's guaranteed that any identities found belongs to a
different user.

## Current behaviour
* Currently, `IsDuplicatedEmail` only accepts an `email` and an `aud`
and uses those fields to check if the `auth.identities` table has
identities with the same email. When this is used in the context of
updating a user's email (`PUT /user`), `IsDuplicatedEmail` will also
include identities that belong to the current user.

---------

Co-authored-by: Joel Lee <lee.yi.jie.joel@gmail.com>
LashaJini pushed a commit to LashaJini/auth that referenced this issue Nov 15, 2024
…er (supabase#1092)

## What kind of change does this PR introduce?
* Fixes supabase#1060, supabase#988 
* Allows one to pass in an optional `currentUser` into
`IsDuplicatedUser` to exclude the user's identities when checking for
duplicates
* This is optional because on signup / admin create user, there won't be
a current user so it's guaranteed that any identities found belongs to a
different user.

## Current behaviour
* Currently, `IsDuplicatedEmail` only accepts an `email` and an `aud`
and uses those fields to check if the `auth.identities` table has
identities with the same email. When this is used in the context of
updating a user's email (`PUT /user`), `IsDuplicatedEmail` will also
include identities that belong to the current user.

---------

Co-authored-by: Joel Lee <lee.yi.jie.joel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants