Demo, all content is generated
Question

Lovable app: users see each other's data after login

Solved · 5201 views · asked by noor_builds · edited

Two test accounts, both see the same list of projects. I thought Supabase separated users automatically.

What I’ve tried

Asked Lovable to "make projects private per user". It added a filter in the frontend, but if I remove the filter in the network tab I still get everything.

Comment
Don't launch before this is fixed. Check what the network tab returns for the projects call, I bet it's every row. priya_ships · edited

2 answers

Marked as helpful by the asker
mira_dev · edited

Supabase does not separate users automatically, RLS does, and it is off by default on new tables. A frontend filter is decoration; the database must refuse.

alter table projects enable row level security;
create policy "own projects" on projects
  for all using (auth.uid() = owner_id) with check (auth.uid() = owner_id);

Then test it the way you already did: remove the filter in the network tab. You should get an empty list. Do this for every table with user data, and assume the same bug exists in every other table Lovable created.

Comment
RLS was off on all four tables. Turned it on and now I see nothing at all, not even my own projects. noor_builds · edited
Expected until you add the policy. RLS with no policy denies everything. Run the create policy statement as well. mira_dev · edited
Done, both accounts only see their own now. Thank you so much. noor_builds · edited
Keep the with check part. Without it a user can still update a row so it belongs to someone else. hannah_reyes · edited
Found this through search, exact same problem in my Lovable app. Fixed in ten minutes. mina_j · edited
lena_ops · edited

Supabase has a Security Advisor in the dashboard that lists tables without RLS. Run it after every Lovable change.

Comment
Security Advisor showed three more warnings, working through them. noor_builds · edited