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

Auth: Update email account will not update the adress to log in #67

Closed
Etheonor opened this issue Feb 14, 2021 · 6 comments
Closed

Auth: Update email account will not update the adress to log in #67

Etheonor opened this issue Feb 14, 2021 · 6 comments
Assignees
Labels
bug Something isn't working UX UX Improvement

Comments

@Etheonor
Copy link

If you update the email adress with supabase.auth.update, it will not replace the old one but create a "new_email" element in your auth.user object.

Therefore, when you try to log in again with the new updated email, it will not work and you'll have to use the old one.

@kiwicopple
Copy link
Member

Thanks for the bug report @Etheonor. I'm going to move this over to the GoTrue repo so we can discuss the expected behaviour.

Possibly related, since this PR occured after our fork was created: netlify/gotrue#243

@kiwicopple kiwicopple transferred this issue from supabase/supabase Feb 14, 2021
@kiwicopple
Copy link
Member

OK I did some testing here and can confirm: supabase/auth-js#57

We need to decide whether to handle this in the client or the server.

We could handle it in the client like this: supabase/auth-js#58. I'm not sure why Netlify chose this strategy to start with

@Etheonor
Copy link
Author

Etheonor commented Feb 25, 2021

Another thing, when we update this new_email element, if you do a supabase.auth.user() right after, you will not have the updated user. You have to logout/login to have the new_mail properly updated.

This is far from ideal

Edit: after further investigation

If you do a auth.refreshSession() and log the result, you'll have the updated user/session. But it seems that the info is not transfered to the context.
Even if I use the onAuthStateChange method, when I perform an email update, this will trigger the User_Updated event, but the session will remain the same...

@icecream78
Copy link
Contributor

@kiwicopple @awalias I've looked though code that implements user change. That code is responsible for email change too, but I am not sure that it has been worked ever. Logic that handles email change placed in handler that requires auth token and has PUT method, not GET. Plus, default variable MAILER_URLPATHS_EMAIL_CHANGE is / and GOTRUE doesn't have handler for that url at all=)
My preposition for fixing that problem is next. In verify handler add new one type - email_change and write corresponding logic for handling changed email.
Or it isn't necessary changes? What do you think about that?

@awalias
Copy link
Member

awalias commented Mar 10, 2021

related: #60

@J0 J0 added bug Something isn't working UX UX Improvement labels Jan 19, 2022
@J0 J0 self-assigned this May 9, 2022
@J0 J0 mentioned this issue Jun 28, 2022
2 tasks
@kangmingtay
Copy link
Member

Hey @Etheonor, i think this issue has been resolved already. You can update your email with supabase.auth.updateUser which will return a user object with the new_email field. You'll have to verify the email change confirmation link that's sent to your email before you can login with the new_email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working UX UX Improvement
Projects
None yet
Development

No branches or pull requests

6 participants