question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Supabase query data based on uid does not work

See original GitHub issue

I created the table and policy via UI and I always get an emtpy list. If my expression is just true I get all my rows.

image

image

var response = await supabaseClient.from('portfolios').select().execute();
    if (response.error == null) {
      final results = response.data as List<dynamic>;
      return results.map((e) => Portfolio.fromMap(e)).toList();
    }
    throw Exception("Error while fetching portfolios");

I tried as well everything via script:

CREATE TABLE portfolios (
  id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  name text,
  user_id uuid references users (id)
);

alter table portfolios
  enable row level security;

create policy "Read own portfolios" ON public.portfolios for select USING ((auth.uid() = portfolios.user_id));

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kiwicopplecommented, Jan 21, 2022

Should I reopen there If needed?

yes please!

0reactions
Sesa1988commented, Jan 21, 2022

It was the singleton/no token in header issue. Thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing User Data - Supabase
Managing User Data. For security purposes, the auth schema is not exposed on the auto-generated API. Even though Supabase provides an auth.users table, ......
Read more >
Row Level Security - Supabase
Secure your data using Postgres Row Level Security.
Read more >
Supabase Documentation
This reference documents every object and method available in Supabase's isomorphic JavaScript library, supabase-js. You can use supabase-js to interact ...
Read more >
Part Three: Policies - Supabase
Supabase Auth Deep Dive Part 3: User Based Access Policies. ... us much more control over what data your users can read to...
Read more >
Auth | Supabase
When you need granular authorization rules, nothing beats PostgreSQL's Row Level Security (RLS). Policies are PostgreSQL's rule engine. They are incredibly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found