zeeshanok
10/20/2021, 5:02 PMsilentworks
10/20/2021, 7:10 PMmikebarkmin
10/20/2021, 9:27 PMmikebarkmin
10/20/2021, 9:28 PMmikebarkmin
10/20/2021, 9:28 PMzeeshanok
10/21/2021, 3:02 AMmembers
made using sql
create table if not exists public.members (
id bigint generated by default as identity primary key not null,
nickname text default '',
user_id uuid references public.profiles not null,
group_id bigint references public.groups on delete cascade not null,
joined_at timestamp without time zone default now(),
unique (user_id, group_id)
);
the policy should give an authorised user all members that are in groups that the current user is in (mutual members)
this would require selecting all the groups the current user is in and then using that query to select all members in those groups.
something like: sql
create policy "Allow mutual members to be able to see each other" on public.members for select using (
members.user_id in (select user_id from public.members where group_id in (select group_id from public.members where user_id = auth.uid()))
);
there is probably a more efficient way but the point of this code is to show you that the policy queries its on table and that causes a recursion errorzeeshanok
10/21/2021, 3:04 AMjason-lynx
10/21/2021, 4:13 AMzeeshanok
10/21/2021, 4:14 AMjason-lynx
10/21/2021, 4:27 AMjason-lynx
10/21/2021, 4:28 AMsupabase_admin
)zeeshanok
10/21/2021, 4:47 AMjason-lynx
10/21/2021, 6:29 AM