Cancel email change request?

I'm trying to figure a way to allowing the user to cancel their email change request. I do have a function that updates these values:
set
email_change = null,
email_change_token_current = '',
email_change_token_new = '',
email_change_confirm_status = 0,
email_change_sent_at = null
set
email_change = null,
email_change_token_current = '',
email_change_token_new = '',
email_change_confirm_status = 0,
email_change_sent_at = null
However, something seems to break, and unable to log back in due to a database schema error.
7 Replies
Smokey
SmokeyOP3w ago
Also I know you're not really supposed to touch the auth table, but I can't figure out any other way to cancel the email change request Here is where I got the idea from for the above snippet: https://github.com/orgs/supabase/discussions/7208
silentworks
silentworks3w ago
Why would you need to cancel the email change request? if the user doesn't confirm the new email by clicking the links the existing email will continue to work as normal.
Smokey
SmokeyOP3w ago
Because in my UI it displays if there is a pending email change. I need a way to cancel the email change. Surely there must be a way to achieve this
silentworks
silentworks3w ago
There is none from any of the SDKs perspective, but you can update the columns in the auth.users table if you wish. But as I said before just like any other service when you do email change, your old email continues to work unless you click the actual link that was sent to you and that link expires after a day if I remember correctly.
Smokey
SmokeyOP3w ago
Yes I'm aware that the old email still works. However, I'm unsure what column in auth.users to change, since it seems to break the login of the user account, when I set email_change to null:
{"code":"unexpected_failure","message":"Database error querying schema"}
{"code":"unexpected_failure","message":"Database error querying schema"}
garyaustin
garyaustin3w ago
email_change has to be empty string if you look at an auth.users row without an email change having been requested. But this will be the problem with changing rows yourself. The way they work could change. Unless Supabase shows the columns in documentation being used (I don't know if there is a list) they could change.
Smokey
SmokeyOP3w ago
yep you're right, I just figured it out this very second

Did you find this page helpful?