Merge branch 'main' into B2B-30
This commit is contained in:
22
supabase/migrations/20250630191934_is_company_admin.sql
Normal file
22
supabase/migrations/20250630191934_is_company_admin.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
create or replace function public.is_company_admin(account_slug text)
|
||||
returns boolean
|
||||
set search_path = ''
|
||||
language plpgsql
|
||||
as $$
|
||||
declare
|
||||
is_owner boolean;
|
||||
begin
|
||||
select exists (
|
||||
select 1
|
||||
from public.accounts_memberships am
|
||||
join public.accounts a on a.id = am.account_id
|
||||
where am.user_id = auth.uid()
|
||||
and am.account_role = 'owner'
|
||||
and a.slug = account_slug
|
||||
) into is_owner;
|
||||
|
||||
return is_owner;
|
||||
end;
|
||||
$$;
|
||||
|
||||
grant execute on function public.is_company_admin(text) to authenticated, service_role;
|
||||
Reference in New Issue
Block a user