Trouble getting RLS working
Hi I am trying to use RLS for the first time. After users authenticate (using google) for the first time, they enter username, interests, and newsletter and privacy opt-ins.
I have the following RLS policy (taken from the templates):
CREATE POLICY "Enable insert for authenticated users only" ON public.profiles
AS PERMISSIVE FOR INSERT
TO authenticated
WITH CHECK (true)
My insert statement js looks like this:
const { data, error } = await supabase
.from('profiles')
.insert([{ id: user.id, username: userParams.username, created_at: new Date(),
locations: userParams.locations, newsletter: userParams.newsletter, privacy: userParams.privacy}])
if (error) {
console.log(error)
}
but I'm getting following error in the console:
code: '42501', details: null, hint: null, message: 'new row violates row-level security policy for table "profiles"'
I don't understand what is going on, as I'm definitely authenticated when trying to insert - am logging the user in the console and it shows as authenticated, with the user_id etc..
I have the following RLS policy (taken from the templates):
CREATE POLICY "Enable insert for authenticated users only" ON public.profiles
AS PERMISSIVE FOR INSERT
TO authenticated
WITH CHECK (true)
My insert statement js looks like this:
const { data, error } = await supabase
.from('profiles')
.insert([{ id: user.id, username: userParams.username, created_at: new Date(),
locations: userParams.locations, newsletter: userParams.newsletter, privacy: userParams.privacy}])
if (error) {
console.log(error)
}
but I'm getting following error in the console:
code: '42501', details: null, hint: null, message: 'new row violates row-level security policy for table "profiles"'
I don't understand what is going on, as I'm definitely authenticated when trying to insert - am logging the user in the console and it shows as authenticated, with the user_id etc..