how do i use a trigger to insert data into a table after a user signs up

I'm trying to automatically insert data into a table whenever a new row is added to the auth.users table. I've created a function to insert this data, and I've also set up a trigger to activate this function when the insert to auth.users happens. However, I'm currently encountering an error with this setup. I've included both the function code and the trigger code for reference this doesn't work for signing up with oauth and magic links in my application rls is disabled on this table for dev purposes currently getting this error from auth logs
{
"component": "api",
"error": "failed to close prepared statement: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02): ERROR: permission denied for table payment_data (SQLSTATE 42501)",
"level": "error",
"method": "POST",
"msg": "500: Database error saving new user",
"referer": "http://localhost:3000/",
"path":"/otp"
}
{
"component": "api",
"error": "failed to close prepared statement: ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02): ERROR: permission denied for table payment_data (SQLSTATE 42501)",
"level": "error",
"method": "POST",
"msg": "500: Database error saving new user",
"referer": "http://localhost:3000/",
"path":"/otp"
}
No description
No description
1 Reply
garyaustin
garyaustin2y ago
Your function needs to be security define type. There is an example in most of the guides, auth user management docs and the SQL editor samples.

Did you find this page helpful?