supabase / auth-js

An isomorphic Javascript library for Supabase Auth.
MIT License
321 stars 153 forks source link

Update user email that previously had no email fails #737

Open Cali93 opened 11 months ago

Cali93 commented 11 months ago

Bug report

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: "my-email@gmail.com" })
  3. Change email confirmation expires, user calls updateUser({ email: "my-email@gmail.com" }) 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

Additional context

Add any other context about the problem here.