Permission denied for stored procedure that updates user's email address in auth.users
See original GitHub issueI created a stored procedure (aka function) in the database that I hoped would allow the user’s email address to be updated from the supabase JS client. When I ran it, I was met with an error message: ‘permission denied for schema auth’
Here’s what my ‘CREATE FUNCTION’ query looks like:
CREATE FUNCTION updateauthemail (new_email text, auth_id text)
RETURNS text AS $updated_data$
DECLARE
updated_data text;
BEGIN
UPDATE auth.users set email = new_email where id = auth_id;
RETURN updated_data;
END;
$updated_data$ LANGUAGE plpgsql;
Do I need to add something to the function when creating it, or pass a certain param through the JS client on my Node.js server? Here’s the function I’m calling through the JS client:
const { data: rpcData, error: rpcErr } = await supabase.rpc(
"updateauthemail",
{
auth_id: authId,
new_email: updatedData.email,
}
);
_Originally posted by @dayvista in https://github.com/supabase/supabase/discussions/573#discussioncomment-358474_
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Grant Permissions on a Stored Procedure - SQL Server
This article describes how to grant permissions on a stored procedure in SQL Server by using SQL Server Management Studio or Transact-SQL.
Read more >EXECUTE permission denied on object - sql - Stack Overflow
First create an executor role and then grant exec permission to this role.Then make your user member of this role.
Read more >SQL Server Execute Permission Denied - DBA Stack Exchange
I have a small app which calls a stored procedure over ODBC using a sysadmin user with login and password. The problem is...
Read more >Grant Execute Or View Permission To Stored Procedures In ...
In this article we'll learn how we can grant execute permission or view permission on stored procedures. We'll also see why users require ......
Read more >Understand the reasons behind permission denied errors ...
To start with one needs to dig deep into the stored procedure to understand the cause of the permission denied error creeping up...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the tip, @steve-chavez That almost did it, but I had to compare my declared
auth_id
variable againstid
rather thanauth.uid()
, like so:That enabled me to pass the id through Node.js like this:
… and it worked! Thanks a ton to both of you for pointing me in the right direction.
@dayvista The
auth.uid() = auth_id;
part in the UPDATE looks wrong.Shouldn’t that be: