auth-js icon indicating copy to clipboard operation
auth-js copied to clipboard

Update user email that previously had no email fails

Open Cali93 opened this issue 2 years ago • 0 comments

Bug report

  • [X] I confirm this is a bug with Supabase, not with my own application.
  • [X] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

If a user signed up with a provider other than email and wants to later on add his email, if the change email confirmation expires it errors out and he can't resend a new confirmation email by calling updateUser again.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Sign up with any provider other than email
  2. Call updateUser({ email: "[email protected]" })
  3. Change email confirmation expires, user calls updateUser({ email: "[email protected]" }) again.
  4. Get error duplicate key value violates unique constraint "identities_pkey"

Expected behavior

This code is checking the email field of the user before creating an identity. But it should really be checking to see if there is an email identity for that user.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • Version of supabase-js: 2.26.0
  • Version of Node.js: 18

Additional context

Add any other context about the problem here.

Cali93 avatar Jul 18 '23 10:07 Cali93