-
Notifications
You must be signed in to change notification settings - Fork 491
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
Describe the bug
When using supabase.auth.admin.updateUserById
to force an email confirm on an anonymous user, there are multiple issues:
- If you only provide an
email_confirm
likeadmin.updateUserById(id, {email_confirm: true})
and you already have the email column set- Then you have the
email_confirmed_at
column set - but no changes for
is_anonymous
,role
oraud
- Then you have the
- If you provide an email and email_confirm like so
admin.updateUserById(id, {email_confirm: true, email})
you get (on top of expectedemail
andemail_confirmed_at
column changes):is_anonymous
set fromtrue
tofalse
- but the
aud
(audience) androle
columns are left toanonymous
Expected behavior
If there is no email provided and email_confirm
is set to true, check if the column is already set.
- If it’s not throw/return an error.
- If it is proceed to the following expected behavior
If the value of email_confirm
can be set to true (whether email was provided or not), do the following changes:
- If row
role
is set toanonymous
set it toauthenticated
- If row
aud
is set toanonymous
set it toauthenticated
- If row
is_anonymous
is set totrue
set it tofalse
This is especially important because if aud
and role
columns are left to anonymous
, methods like:
supabase.auth.admin.generateLink({
email,
type: "recovery",
})
Will throw User with this email not found
This last error message is also an issue. The user exists with this email but it’s not considered because it’s an anonymous one. The error message could be Authenticated user with this email not found
System information
- OS:
macOS
- Version of supabase-js:
2.46.2
- Version of Node.js:
20.18.1
Additional context
#1578 Issue that partially fixed the situation
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
MathieuUrstein commentedon May 15, 2025
In case someone has the same issue here the kind of stuff you can do to help: