@flowselections/floriday-verkoop-module 1.0.115 → 1.0.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowselections/floriday-verkoop-module",
3
- "version": "1.0.115",
3
+ "version": "1.0.116",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -1315,6 +1315,10 @@ BEGIN
1315
1315
  WHERE floriday_id = NEW.floriday_id;
1316
1316
 
1317
1317
  IF v_num IS NULL OR v_num !~ '^FO-[0-9]{7}$' THEN
1318
+ IF to_regprocedure('public.next_order_number_for_date(text,timestamp with time zone)') IS NULL THEN
1319
+ RAISE WARNING 'Ordernummer niet toegekend: next_order_number_for_date ontbreekt';
1320
+ RETURN NEW;
1321
+ END IF;
1318
1322
  v_num := public.next_order_number_for_date('FO', NEW.created_at);
1319
1323
  INSERT INTO public.floriday_order_number_map(floriday_id, order_number)
1320
1324
  VALUES (NEW.floriday_id, v_num)
@@ -2170,6 +2174,7 @@ AS $function$
2170
2174
  DECLARE
2171
2175
  v_uid uuid := auth.uid();
2172
2176
  v_role public.app_role;
2177
+ v_ctx text;
2173
2178
  BEGIN
2174
2179
  IF public.verkoop_is_server() THEN RETURN; END IF;
2175
2180
  IF p_level = 'server' THEN
@@ -2178,6 +2183,13 @@ BEGIN
2178
2183
  IF v_uid IS NOT NULL THEN RETURN; END IF;
2179
2184
  ELSIF p_level = 'keten' THEN
2180
2185
  IF v_uid IS NOT NULL OR pg_trigger_depth() > 0 THEN RETURN; END IF;
2186
+ ELSIF p_level = 'keten_genest' THEN
2187
+ -- Ingelogd, trigger, of geneste aanroep vanuit een andere databasefunctie.
2188
+ -- Genest = de aanroepstapel (PG_CONTEXT) bevat meer dan deze poort en de
2189
+ -- beschermde functie zelf. Een rechtstreekse API-aanroep heeft er precies twee.
2190
+ IF v_uid IS NOT NULL OR pg_trigger_depth() > 0 THEN RETURN; END IF;
2191
+ GET DIAGNOSTICS v_ctx = PG_CONTEXT;
2192
+ IF (SELECT count(*) FROM regexp_split_to_table(v_ctx, E'\n') l WHERE l ~ '^(PL/pgSQL|SQL) function ') > 2 THEN RETURN; END IF;
2181
2193
  ELSIF p_level = 'rol' THEN
2182
2194
  IF v_uid IS NOT NULL AND p_roles IS NOT NULL THEN
2183
2195
  FOREACH v_role IN ARRAY p_roles LOOP
@@ -2214,7 +2226,7 @@ CREATE OR REPLACE FUNCTION public.verkoop_guarded_functions()
2214
2226
  AS $function$
2215
2227
  SELECT * FROM (VALUES
2216
2228
  ('verkoop_insert_manual_order(jsonb,jsonb,text)', 'server', NULL, NULL),
2217
- ('verkoop_create_order(text,text,uuid,date,uuid,uuid,jsonb,text,text,boolean,text,boolean,text)', 'ingelogd', NULL, 'verkoop_create_order: wacht op controle Aanbiedingsmail'),
2229
+ ('verkoop_create_order(text,text,uuid,date,uuid,uuid,jsonb,text,text,boolean,text,boolean,text)', 'keten_genest', NULL, 'verkoop_create_order: geneste aanroep toegestaan (Aanbiedingsmail), wacht op ronde Aanbiedingsmail. Let op: elke functie die anon mag uitvoeren en verkoop_create_order aanroept, wordt zo een open deur; de bescherming ligt dan bij die buitenste functie'),
2218
2230
  ('verkoop_packing_drift_report()', 'rol', 'admin,superadmin', NULL),
2219
2231
  ('verkoop_packing_drift_apply(uuid[])', 'rol', 'admin,superadmin', NULL),
2220
2232
  ('assign_floriday_order_numbers(text[])', 'ingelogd', NULL, NULL),
@@ -2272,6 +2284,11 @@ BEGIN
2272
2284
  END IF;');
2273
2285
  END IF;
2274
2286
 
2287
+ IF r.sig LIKE 'verkoop_create_order(%' THEN
2288
+ v_new := replace(v_new, 'PERFORM public.verkoop_assert_caller(''ingelogd''); -- verkoop-poort',
2289
+ 'PERFORM public.verkoop_assert_caller(''keten_genest''); -- verkoop-poort');
2290
+ END IF;
2291
+
2275
2292
  IF position('verkoop_assert_caller' IN v_new) = 0 THEN
2276
2293
  v_call := format('PERFORM public.verkoop_assert_caller(%L%s); -- verkoop-poort',
2277
2294
  r.niveau,