supabase-js
supabase-js copied to clipboard
Cannot clear user phone number using `supabase.auth.admin.updateUserById` function
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
Using the supabase.auth.admin.updateUserById
and passing phone as an empty string, I would expect the phone value to be set to blank, passing null also give an API error
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Setup your supabase client with admin priviledges
- call the
supabase.auth.admin.updateUserById
:
await supabase.auth.admin.updateUserById(
userId,
{ phone: '' }, // or { phone: null }
);
Expected behavior
Phone is successfully cleard.
System information
- Version of supabase-js: 2.42.0
Additional context
Add any other context about the problem here.
It doesn't work on this either.
const { data, error } = await supabase.auth.updateUser({ phone: "" });
Is there any way around this?
Might need to tag the maintainers to get some info/update
Something like this could work
create or replace function clear_user_phone(user_id uuid)
returns bool
security definer
as
$$
begin
update auth.users set phone = '',
phone_confirmed_at = null,
phone_change = ''
where id = user_id;
return true;
end;
$$ language plpgsql;
const { data, error } = await supabase.rpc('clear_user_phone', {
user_id: user.id,
})
if (error) {
console.error(error)
}