Can't insert rows into Supabase profile table even after creating the RLS policy to do so for the sign up feature

Again, I am quite new to Supabase so I apologize in advance if I don't provide clear details in this post or mess up with some terms or something

Basically, I am doing auth using Supabase and have this table called "profiles" with columns:

id - UUID username - text email - text

now when I create a new account using Supabase, it works, the account gets registered and shows up in the auth tab, but the new row doesn't get inserted into profiles?

    user = response.user


    if user:
        resp = supabase.table("profiles").insert({
            "id": user.id,
            "username": username,
            "email": email
        }).execute()

        print(resp)

        request.session["user_id"] = user.id
        request.session["username"] = username


        return redirect("home")

Now, my RLS for the profiles table is:

  • Enable insert for authenticated users only,
  • INSERT,
  • anon, authenticated

and I am using a service key to create the supabase client.

Even after all that, I keep getting the error -> APIError: {'message': 'new row violates row-level security policy for table "profiles"', 'code': '42501', ...}

PLEASE HELP ME I HAVE NO IDEA HOW TO FIX THIS, I almost let AI take over my code atp but nahh I'm not that desperate 💔

Вернуться на верх