Skip to content

Permission denied for stored procedure that updates user's email address in auth.users  #127

@GodGardensGuns

Description

@GodGardensGuns

I 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 supabase/supabase#573 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions