سامانه صدور فاکتور و حسابداری
fix(finance): preserve global admin guard audit access
davoodmehraban89 committed
Nov 15, 2026 at 13:06 UTC
6af1a2bf4ae52d733ffcf69bb92c9fc9e1d82e7e
1 file changed
+4
-3
supabase/migrations/20261115130000_wp1_guard_audit_tenant_scope.sql
+4
-3
@@ -6,9 +6,10 @@ RETURNS void LANGUAGE plpgsql SECURITY DEFINER SET search_path=''
6
AS $fn$
7
DECLARE v_actor uuid:=auth.uid();
8
BEGIN
9
- IF v_actor IS NULL OR p_org IS NULL OR NOT EXISTS(
10
- SELECT 1 FROM public.organization_members
11
- WHERE organization_id=p_org AND user_id=v_actor AND status='active') THEN
9
+ IF v_actor IS NULL OR p_org IS NULL OR (
10
+ NOT EXISTS(SELECT 1 FROM public.organization_members
11
+ WHERE organization_id=p_org AND user_id=v_actor AND status='active')
12
+ AND NOT coalesce(public.is_admin(),false)) THEN
13
RAISE EXCEPTION 'FINORA_GUARD_AUDIT_SCOPE_FORBIDDEN' USING ERRCODE='42501';
14
END IF;
15
IF coalesce(length(p_message),0)>2000 OR coalesce(p_state,'') !~ '^[0-9A-Z]{5}$' THEN