Hi there! I’m using the below to define a custom action so that I can create a record in my users table in Supabase. However, I’m running into this issue 'message: ‘new row violates row-level security policy for table “users_info”’. I’m not quite sure what user role Auth0 is using to access Supabase so would appreciate any guidance on how to configure the row-level security for the Supabase users table so that Auth0 custom actions can insert the data into the table. Thanks!
exports.onExecutePostLogin = async (event, api) => {
if (event.stats.logins_count == 1) {
const { createClient } = require(‘@supabase/supabase-js’);
const supabaseUrl = event.secrets.SUPABASEURL;
const supabaseKey = event.secrets.SUPABASEKEY;
const supabase = createClient(supabaseUrl, supabaseKey,{
schema: ‘private’});
const { user } = event;
// Create a new record in Supabase
const { data, error } = await supabase.from('users_info').insert(
{
auth0_user_id: event.user.user_id,
email: event.user.email,
first_name: event.user.first_name,
last_name: event.user.last_name
});
if (error) {
console.error('Error creating user record:', error);
return;
}
console.log('User record created successfully');
}}