I'm trying to insert a row in my table which has RLS enabled and the Enable insert for authenticated users only
policy added.
Unfortunately, I cannot insert even though I'm correctly login.
Steps to reproduce:
- Create submissions table
create table submission (
stuff text
);
- Enable RLS
alter table submissions
enable row level security
- Add Policy
CREATE POLICY "Enable insert for authenticated users only" ON public.submissions FOR INSERT WITH CHECK (auth.role() = 'authenticated');
On client, I log in using magic links (the object is correctly added in localstorage so I know I'm log in)
I try to insert
const { data, error } = await supabase
.from("submissions")
.insert({ stuff: 'hello' });
The Authorization Bearer <Jwt>
is present in http call.
- But I got error
{
"hint":null,
"message":"new row violates row-level security policy for table \"submissions\"",
"code":"42501",
"details":null
}
What am I doing wrong here?