@nextblock-cms/db 0.11.3 → 0.12.0
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/lib/supabase/server.d.ts +9 -0
- package/lib/supabase/types.d.ts +9 -0
- package/package.json +1 -1
- package/supabase/migrations/00000000000000_baseline_schema.sql +2454 -0
- package/supabase/migrations/00000000000001_baseline_constraints_and_indexes.sql +1071 -0
- package/supabase/migrations/00000000000002_baseline_security_and_grants.sql +1335 -0
- package/supabase/migrations/00000000000003_baseline_seed.sql +468 -0
- package/supabase/migrations/00000000000004_default_logo_email_safe.sql +24 -0
- package/supabase/migrations/00000000000005_add_custom_canonical.sql +13 -0
- package/supabase/migrations/00000000000006_home_live_demo_promo.sql +67 -0
- package/supabase/templates/confirmation.html +1 -1
- package/supabase/templates/email_change.html +1 -1
- package/supabase/templates/invite.html +1 -1
- package/supabase/templates/magic_link.html +1 -1
- package/supabase/templates/reauthentication.html +1 -1
- package/supabase/templates/recovery.html +1 -1
- package/supabase/migrations/00000000000000_setup_foundation_and_enums.sql +0 -40
- package/supabase/migrations/00000000000001_setup_cms_core.sql +0 -124
- package/supabase/migrations/00000000000002_setup_content_tables.sql +0 -138
- package/supabase/migrations/00000000000003_setup_catalog_and_licensing.sql +0 -160
- package/supabase/migrations/00000000000004_setup_fulfillment_shipping_taxes_and_currencies.sql +0 -797
- package/supabase/migrations/00000000000005_setup_functions_and_triggers.sql +0 -767
- package/supabase/migrations/00000000000006_setup_rls_and_grants.sql +0 -872
- package/supabase/migrations/00000000000007_setup_indexes.sql +0 -158
- package/supabase/migrations/00000000000008_seed_platform_defaults.sql +0 -155
- package/supabase/migrations/00000000000009_seed_translations.sql +0 -801
- package/supabase/migrations/00000000000010_seed_content_scaffold.sql +0 -1088
- package/supabase/migrations/00000000000011_setup_cortex_ai_settings.sql +0 -81
- package/supabase/migrations/00000000000012_setup_commerce_coupons.sql +0 -275
- package/supabase/migrations/00000000000013_setup_cortex_ai_db_mutation_audit.sql +0 -47
- package/supabase/migrations/00000000000014_setup_content_drafts.sql +0 -119
- package/supabase/migrations/00000000000015_setup_product_drafts.sql +0 -97
- package/supabase/migrations/00000000000016_add_feature_image_to_pages.sql +0 -8
- package/supabase/migrations/00000000000017_add_product_blocks.sql +0 -118
- package/supabase/migrations/00000000000018_setup_bot_protection_settings.sql +0 -77
- package/supabase/migrations/00000000000019_add_product_categories.sql +0 -64
- package/supabase/migrations/00000000000020_add_category_translations.sql +0 -10
- package/supabase/migrations/00000000000021_migrate_hero_blocks_to_sections.sql +0 -29
- package/supabase/migrations/00000000000022_seed_cortex_ai_guide_post.sql +0 -184
- package/supabase/migrations/00000000000023_setup_custom_block_definitions.sql +0 -183
- package/supabase/migrations/00000000000024_setup_ucp_cart_sessions.sql +0 -72
- package/supabase/migrations/00000000000025_add_sale_schedule_columns.sql +0 -406
- package/supabase/migrations/00000000000026_seed_on_sale_translation.sql +0 -9
- package/supabase/migrations/00000000000027_setup_privacy_and_mfa.sql +0 -479
- package/supabase/migrations/00000000000028_clear_advisor_warnings.sql +0 -93
- package/supabase/migrations/00000000000029_refresh_setup_article.sql +0 -252
- package/supabase/migrations/00000000000030_setup_system_configuration.sql +0 -80
- package/supabase/migrations/00000000000031_seed_footer_navigation.sql +0 -85
- package/supabase/migrations/00000000000032_neutralize_seeded_contact_emails.sql +0 -34
- package/supabase/migrations/00000000000033_setup_config_settings.sql +0 -99
- package/supabase/migrations/00000000000034_enable_staff_2fa_reminder_default.sql +0 -15
- package/supabase/migrations/00000000000035_reassert_advisor_fixes.sql +0 -33
- package/supabase/migrations/00000000000036_setup_system_alerts.sql +0 -72
- package/supabase/migrations/00000000000037_refresh_setup_article_install_paths.sql +0 -317
- package/supabase/migrations/00000000000038_seed_consent_banner_translations.sql +0 -126
- package/supabase/migrations/00000000000039_setup_interactions.sql +0 -153
- package/supabase/migrations/00000000000040_add_profiles_fk_to_interactions.sql +0 -8
- package/supabase/migrations/00000000000041_seed_interactions_translations.sql +0 -145
- package/supabase/migrations/00000000000042_seed_deploy_to_vercel_ctas.sql +0 -72
- package/supabase/migrations/00000000000043_swap_home_hero_media_to_youtube.sql +0 -42
- package/supabase/migrations/00000000000044_swap_article_nx_graph_for_youtube.sql +0 -66
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
-- 00000000000027_setup_privacy_and_mfa.sql
|
|
2
|
-
-- Canadian privacy compliance (Quebec Law 25 / CASL) + two-factor authentication.
|
|
3
|
-
--
|
|
4
|
-
-- Adds:
|
|
5
|
-
-- * privacy_consent_logs - immutable audit trail of consent decisions (service-role writes only)
|
|
6
|
-
-- * user_security_settings - per-user MFA configuration (totp | email)
|
|
7
|
-
-- * user_trusted_devices - revocable "remember this device" records that gate the 2FA bypass
|
|
8
|
-
-- * email_2fa_challenges - short-lived hashed 6-digit email codes (service-role only)
|
|
9
|
-
-- Seeds:
|
|
10
|
-
-- * privacy_settings / security_settings defaults into site_settings
|
|
11
|
-
-- * /privacy-policy + /terms-of-service pages (EN + FR) as text blocks, with the
|
|
12
|
-
-- Terms aligned to NextBlock's actual license (AGPL-3.0, see LICENSE.md)
|
|
13
|
-
-- * the remember_this_device sign-in translation
|
|
14
|
-
--
|
|
15
|
-
-- Conventions mirror existing migrations: gen_random_uuid(), timestamptz DEFAULT now(),
|
|
16
|
-
-- explicit per-table GRANTs, RLS with service_role FOR ALL and role-scoped authenticated policies.
|
|
17
|
-
|
|
18
|
-
-- ---------------------------------------------------------------------------
|
|
19
|
-
-- 1. privacy_consent_logs
|
|
20
|
-
-- ---------------------------------------------------------------------------
|
|
21
|
-
CREATE TABLE IF NOT EXISTS public.privacy_consent_logs (
|
|
22
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
23
|
-
consent_token text NOT NULL UNIQUE,
|
|
24
|
-
categories jsonb NOT NULL DEFAULT '{"necessary": true, "analytics": false, "marketing": false}'::jsonb
|
|
25
|
-
CHECK (jsonb_typeof(categories) = 'object'),
|
|
26
|
-
ip_masked text,
|
|
27
|
-
user_agent text,
|
|
28
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
COMMENT ON TABLE public.privacy_consent_logs IS
|
|
32
|
-
'Immutable audit log of visitor consent decisions for Quebec Law 25 / PIPEDA accountability.';
|
|
33
|
-
COMMENT ON COLUMN public.privacy_consent_logs.consent_token IS
|
|
34
|
-
'Opaque token also stored in the nb_consent_preference cookie to correlate a decision with its record.';
|
|
35
|
-
COMMENT ON COLUMN public.privacy_consent_logs.ip_masked IS
|
|
36
|
-
'Partially masked IP (e.g. 203.0.113.x) - never store a full address for an analytics/marketing consent log.';
|
|
37
|
-
|
|
38
|
-
CREATE INDEX IF NOT EXISTS idx_privacy_consent_logs_created_at
|
|
39
|
-
ON public.privacy_consent_logs (created_at DESC);
|
|
40
|
-
|
|
41
|
-
ALTER TABLE public.privacy_consent_logs ENABLE ROW LEVEL SECURITY;
|
|
42
|
-
|
|
43
|
-
GRANT SELECT ON public.privacy_consent_logs TO authenticated;
|
|
44
|
-
GRANT ALL ON public.privacy_consent_logs TO service_role;
|
|
45
|
-
|
|
46
|
-
DROP POLICY IF EXISTS privacy_consent_logs_admin_read_policy ON public.privacy_consent_logs;
|
|
47
|
-
CREATE POLICY privacy_consent_logs_admin_read_policy
|
|
48
|
-
ON public.privacy_consent_logs
|
|
49
|
-
FOR SELECT
|
|
50
|
-
TO authenticated
|
|
51
|
-
USING ((SELECT public.get_current_user_role()) = 'ADMIN');
|
|
52
|
-
|
|
53
|
-
DROP POLICY IF EXISTS privacy_consent_logs_service_role_policy ON public.privacy_consent_logs;
|
|
54
|
-
CREATE POLICY privacy_consent_logs_service_role_policy
|
|
55
|
-
ON public.privacy_consent_logs
|
|
56
|
-
FOR ALL
|
|
57
|
-
TO service_role
|
|
58
|
-
USING (true)
|
|
59
|
-
WITH CHECK (true);
|
|
60
|
-
|
|
61
|
-
-- ---------------------------------------------------------------------------
|
|
62
|
-
-- 2. user_security_settings
|
|
63
|
-
-- ---------------------------------------------------------------------------
|
|
64
|
-
CREATE TABLE IF NOT EXISTS public.user_security_settings (
|
|
65
|
-
user_id uuid PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
66
|
-
mfa_enabled boolean NOT NULL DEFAULT false,
|
|
67
|
-
mfa_type text CHECK (mfa_type IN ('totp', 'email')),
|
|
68
|
-
updated_at timestamptz NOT NULL DEFAULT now()
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
COMMENT ON TABLE public.user_security_settings IS
|
|
72
|
-
'Per-user multi-factor configuration. mfa_type is NULL until a factor is enrolled.';
|
|
73
|
-
|
|
74
|
-
ALTER TABLE public.user_security_settings ENABLE ROW LEVEL SECURITY;
|
|
75
|
-
|
|
76
|
-
GRANT SELECT, INSERT, UPDATE ON public.user_security_settings TO authenticated;
|
|
77
|
-
GRANT ALL ON public.user_security_settings TO service_role;
|
|
78
|
-
|
|
79
|
-
DROP POLICY IF EXISTS user_security_settings_select_own_policy ON public.user_security_settings;
|
|
80
|
-
CREATE POLICY user_security_settings_select_own_policy
|
|
81
|
-
ON public.user_security_settings
|
|
82
|
-
FOR SELECT
|
|
83
|
-
TO authenticated
|
|
84
|
-
USING ((SELECT auth.uid()) = user_id);
|
|
85
|
-
|
|
86
|
-
DROP POLICY IF EXISTS user_security_settings_insert_own_policy ON public.user_security_settings;
|
|
87
|
-
CREATE POLICY user_security_settings_insert_own_policy
|
|
88
|
-
ON public.user_security_settings
|
|
89
|
-
FOR INSERT
|
|
90
|
-
TO authenticated
|
|
91
|
-
WITH CHECK ((SELECT auth.uid()) = user_id);
|
|
92
|
-
|
|
93
|
-
DROP POLICY IF EXISTS user_security_settings_update_own_policy ON public.user_security_settings;
|
|
94
|
-
CREATE POLICY user_security_settings_update_own_policy
|
|
95
|
-
ON public.user_security_settings
|
|
96
|
-
FOR UPDATE
|
|
97
|
-
TO authenticated
|
|
98
|
-
USING ((SELECT auth.uid()) = user_id)
|
|
99
|
-
WITH CHECK ((SELECT auth.uid()) = user_id);
|
|
100
|
-
|
|
101
|
-
DROP POLICY IF EXISTS user_security_settings_service_role_policy ON public.user_security_settings;
|
|
102
|
-
CREATE POLICY user_security_settings_service_role_policy
|
|
103
|
-
ON public.user_security_settings
|
|
104
|
-
FOR ALL
|
|
105
|
-
TO service_role
|
|
106
|
-
USING (true)
|
|
107
|
-
WITH CHECK (true);
|
|
108
|
-
|
|
109
|
-
-- ---------------------------------------------------------------------------
|
|
110
|
-
-- 3. user_trusted_devices ("Remember this device")
|
|
111
|
-
-- ---------------------------------------------------------------------------
|
|
112
|
-
CREATE TABLE IF NOT EXISTS public.user_trusted_devices (
|
|
113
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
114
|
-
user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
115
|
-
device_hash text NOT NULL UNIQUE,
|
|
116
|
-
browser_metadata text,
|
|
117
|
-
expires_at timestamptz NOT NULL,
|
|
118
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
COMMENT ON TABLE public.user_trusted_devices IS
|
|
122
|
-
'SHA-256 hashes of trusted-device tokens. A 2FA bypass is only honoured when a non-expired row matches the cookie token, so deleting a row instantly revokes trust.';
|
|
123
|
-
COMMENT ON COLUMN public.user_trusted_devices.device_hash IS
|
|
124
|
-
'SHA-256 of the raw token held in the nb_trusted_device cookie. The raw token is never stored.';
|
|
125
|
-
|
|
126
|
-
CREATE INDEX IF NOT EXISTS idx_user_trusted_devices_user_id
|
|
127
|
-
ON public.user_trusted_devices (user_id);
|
|
128
|
-
CREATE INDEX IF NOT EXISTS idx_user_trusted_devices_expires_at
|
|
129
|
-
ON public.user_trusted_devices (expires_at);
|
|
130
|
-
|
|
131
|
-
ALTER TABLE public.user_trusted_devices ENABLE ROW LEVEL SECURITY;
|
|
132
|
-
|
|
133
|
-
GRANT SELECT, DELETE ON public.user_trusted_devices TO authenticated;
|
|
134
|
-
GRANT ALL ON public.user_trusted_devices TO service_role;
|
|
135
|
-
|
|
136
|
-
-- Users can list their own devices (Security panel) and revoke them, but creation
|
|
137
|
-
-- happens server-side via the service role so the raw token is hashed before storage.
|
|
138
|
-
DROP POLICY IF EXISTS user_trusted_devices_select_own_policy ON public.user_trusted_devices;
|
|
139
|
-
CREATE POLICY user_trusted_devices_select_own_policy
|
|
140
|
-
ON public.user_trusted_devices
|
|
141
|
-
FOR SELECT
|
|
142
|
-
TO authenticated
|
|
143
|
-
USING ((SELECT auth.uid()) = user_id);
|
|
144
|
-
|
|
145
|
-
DROP POLICY IF EXISTS user_trusted_devices_delete_own_policy ON public.user_trusted_devices;
|
|
146
|
-
CREATE POLICY user_trusted_devices_delete_own_policy
|
|
147
|
-
ON public.user_trusted_devices
|
|
148
|
-
FOR DELETE
|
|
149
|
-
TO authenticated
|
|
150
|
-
USING ((SELECT auth.uid()) = user_id);
|
|
151
|
-
|
|
152
|
-
DROP POLICY IF EXISTS user_trusted_devices_service_role_policy ON public.user_trusted_devices;
|
|
153
|
-
CREATE POLICY user_trusted_devices_service_role_policy
|
|
154
|
-
ON public.user_trusted_devices
|
|
155
|
-
FOR ALL
|
|
156
|
-
TO service_role
|
|
157
|
-
USING (true)
|
|
158
|
-
WITH CHECK (true);
|
|
159
|
-
|
|
160
|
-
-- ---------------------------------------------------------------------------
|
|
161
|
-
-- 4. email_2fa_challenges (service-role only - codes are sensitive)
|
|
162
|
-
-- ---------------------------------------------------------------------------
|
|
163
|
-
CREATE TABLE IF NOT EXISTS public.email_2fa_challenges (
|
|
164
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
165
|
-
user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
|
|
166
|
-
token_hash text NOT NULL,
|
|
167
|
-
expires_at timestamptz NOT NULL,
|
|
168
|
-
consumed_at timestamptz,
|
|
169
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
COMMENT ON TABLE public.email_2fa_challenges IS
|
|
173
|
-
'Short-lived SHA-256 hashes of 6-digit email verification codes. Readable/writable only by the service role.';
|
|
174
|
-
|
|
175
|
-
CREATE INDEX IF NOT EXISTS idx_email_2fa_challenges_user_id
|
|
176
|
-
ON public.email_2fa_challenges (user_id);
|
|
177
|
-
CREATE INDEX IF NOT EXISTS idx_email_2fa_challenges_expires_at
|
|
178
|
-
ON public.email_2fa_challenges (expires_at);
|
|
179
|
-
|
|
180
|
-
ALTER TABLE public.email_2fa_challenges ENABLE ROW LEVEL SECURITY;
|
|
181
|
-
|
|
182
|
-
GRANT ALL ON public.email_2fa_challenges TO service_role;
|
|
183
|
-
|
|
184
|
-
-- No authenticated/anon grants and no permissive authenticated policy: all access
|
|
185
|
-
-- flows through service-role server actions.
|
|
186
|
-
DROP POLICY IF EXISTS email_2fa_challenges_service_role_policy ON public.email_2fa_challenges;
|
|
187
|
-
CREATE POLICY email_2fa_challenges_service_role_policy
|
|
188
|
-
ON public.email_2fa_challenges
|
|
189
|
-
FOR ALL
|
|
190
|
-
TO service_role
|
|
191
|
-
USING (true)
|
|
192
|
-
WITH CHECK (true);
|
|
193
|
-
|
|
194
|
-
-- ---------------------------------------------------------------------------
|
|
195
|
-
-- 5. Default site_settings (do not clobber existing admin edits)
|
|
196
|
-
-- ---------------------------------------------------------------------------
|
|
197
|
-
INSERT INTO public.site_settings (key, value) VALUES
|
|
198
|
-
('privacy_settings', '{
|
|
199
|
-
"banner_enabled": true,
|
|
200
|
-
"gtm_id": "",
|
|
201
|
-
"ga_measurement_id": "",
|
|
202
|
-
"custom_scripts": "",
|
|
203
|
-
"corporate": { "legal_name": "", "address": "", "support_email": "" }
|
|
204
|
-
}'::jsonb),
|
|
205
|
-
('security_settings', '{
|
|
206
|
-
"trusted_device_days": 30,
|
|
207
|
-
"enforce_staff_2fa": false
|
|
208
|
-
}'::jsonb)
|
|
209
|
-
ON CONFLICT (key) DO NOTHING;
|
|
210
|
-
|
|
211
|
-
-- ---------------------------------------------------------------------------
|
|
212
|
-
-- 6. Seed /privacy-policy and /terms-of-service pages (EN + FR) as text blocks.
|
|
213
|
-
-- Pages are metadata-only; the actual copy lives in blocks.content.html_content.
|
|
214
|
-
-- The Terms reflect NextBlock's real license (AGPL-3.0, per LICENSE.md).
|
|
215
|
-
-- ---------------------------------------------------------------------------
|
|
216
|
-
DO $seed$
|
|
217
|
-
DECLARE
|
|
218
|
-
v_en bigint;
|
|
219
|
-
v_fr bigint;
|
|
220
|
-
v_privacy_group uuid;
|
|
221
|
-
v_terms_group uuid;
|
|
222
|
-
v_page_id bigint;
|
|
223
|
-
BEGIN
|
|
224
|
-
SELECT id INTO v_en FROM public.languages WHERE code = 'en' LIMIT 1;
|
|
225
|
-
SELECT id INTO v_fr FROM public.languages WHERE code = 'fr' LIMIT 1;
|
|
226
|
-
|
|
227
|
-
IF v_en IS NULL THEN
|
|
228
|
-
RAISE NOTICE 'Default language "en" not found; skipping privacy/terms page seed.';
|
|
229
|
-
RETURN;
|
|
230
|
-
END IF;
|
|
231
|
-
|
|
232
|
-
-- Reuse an existing translation_group_id if these pages were seeded before.
|
|
233
|
-
SELECT translation_group_id INTO v_privacy_group
|
|
234
|
-
FROM public.pages WHERE slug = 'privacy-policy' AND language_id = v_en LIMIT 1;
|
|
235
|
-
IF v_privacy_group IS NULL THEN v_privacy_group := gen_random_uuid(); END IF;
|
|
236
|
-
|
|
237
|
-
SELECT translation_group_id INTO v_terms_group
|
|
238
|
-
FROM public.pages WHERE slug = 'terms-of-service' AND language_id = v_en LIMIT 1;
|
|
239
|
-
IF v_terms_group IS NULL THEN v_terms_group := gen_random_uuid(); END IF;
|
|
240
|
-
|
|
241
|
-
-- ----- Privacy Policy (EN) -----
|
|
242
|
-
INSERT INTO public.pages (language_id, title, slug, status, meta_title, meta_description, translation_group_id)
|
|
243
|
-
VALUES (
|
|
244
|
-
v_en, 'Privacy Policy', 'privacy-policy', 'published',
|
|
245
|
-
'Privacy Policy',
|
|
246
|
-
'How we collect, use, disclose, and protect your personal information under Quebec Law 25, PIPEDA, and CASL.',
|
|
247
|
-
v_privacy_group
|
|
248
|
-
)
|
|
249
|
-
ON CONFLICT (language_id, slug) DO UPDATE
|
|
250
|
-
SET title = EXCLUDED.title, status = EXCLUDED.status,
|
|
251
|
-
meta_title = EXCLUDED.meta_title, meta_description = EXCLUDED.meta_description
|
|
252
|
-
RETURNING id INTO v_page_id;
|
|
253
|
-
|
|
254
|
-
DELETE FROM public.blocks WHERE page_id = v_page_id;
|
|
255
|
-
INSERT INTO public.blocks (page_id, language_id, block_type, content, "order")
|
|
256
|
-
VALUES (v_page_id, v_en, 'text', jsonb_build_object('html_content', $html$
|
|
257
|
-
<h1>Privacy Policy</h1>
|
|
258
|
-
<p><em>Last updated: June 4, 2026</em></p>
|
|
259
|
-
<p>NextBlock™ CMS ("we", "us", or "our") respects your privacy and is committed to protecting your personal information in accordance with Quebec's <em>Act respecting the protection of personal information in the private sector</em> (Law 25), the federal <em>Personal Information Protection and Electronic Documents Act</em> (PIPEDA), and Canada's Anti-Spam Legislation (CASL).</p>
|
|
260
|
-
|
|
261
|
-
<h2>1. Person responsible for personal information</h2>
|
|
262
|
-
<p>Our Privacy Officer is responsible for our compliance with applicable privacy laws. You may reach them at <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>.</p>
|
|
263
|
-
|
|
264
|
-
<h2>2. What we collect</h2>
|
|
265
|
-
<ul>
|
|
266
|
-
<li><strong>Account information</strong> — name, email address, and credentials when you register.</li>
|
|
267
|
-
<li><strong>Usage and device data</strong> — collected only with your consent through analytics technologies.</li>
|
|
268
|
-
<li><strong>Communications</strong> — messages you send us and your marketing preferences.</li>
|
|
269
|
-
</ul>
|
|
270
|
-
|
|
271
|
-
<h2>3. Why we collect it and your consent</h2>
|
|
272
|
-
<p>We collect personal information for clearly identified purposes: to provide and secure our services, to communicate with you, and — only with your express, opt-in consent — for analytics and marketing. Consistent with Law 25, non-essential cookies and trackers remain disabled until you actively accept them, and you may withdraw your consent at any time.</p>
|
|
273
|
-
|
|
274
|
-
<h2>4. Cookies and tracking technologies</h2>
|
|
275
|
-
<p>Strictly necessary cookies keep the site working and require no consent. Analytics and marketing technologies are loaded <strong>only after</strong> you opt in through our consent banner. Your choice is recorded so we can honour it and demonstrate accountability.</p>
|
|
276
|
-
|
|
277
|
-
<h2>5. Disclosure and sharing</h2>
|
|
278
|
-
<p>We do not sell your personal information. We share it only with service providers who help us operate the platform under contractual confidentiality obligations, or where required by law.</p>
|
|
279
|
-
|
|
280
|
-
<h2>6. Retention</h2>
|
|
281
|
-
<p>We keep personal information only for as long as necessary to fulfil the purposes described above or as required by law, after which it is securely destroyed or anonymized.</p>
|
|
282
|
-
|
|
283
|
-
<h2>7. Your rights</h2>
|
|
284
|
-
<p>Subject to applicable law, you have the right to access, rectify, and delete your personal information, to withdraw consent, to data portability, and to be informed about automated processing. To exercise these rights, contact our Privacy Officer at <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>.</p>
|
|
285
|
-
|
|
286
|
-
<h2>8. Commercial electronic messages (CASL)</h2>
|
|
287
|
-
<p>We send commercial electronic messages only with your consent. Every message identifies us and includes a working unsubscribe mechanism that we honour promptly.</p>
|
|
288
|
-
|
|
289
|
-
<h2>9. Safeguards</h2>
|
|
290
|
-
<p>We use appropriate physical, organizational, and technological measures — including encryption in transit and access controls — to protect personal information against loss, theft, and unauthorized access.</p>
|
|
291
|
-
|
|
292
|
-
<h2>10. Open-source software</h2>
|
|
293
|
-
<p>NextBlock™ CMS is free, open-source software distributed under the GNU Affero General Public License v3. When you self-host NextBlock, you are the operator responsible for the personal information processed by your own deployment, and this policy serves as a starting point you may adapt to your organization.</p>
|
|
294
|
-
|
|
295
|
-
<h2>11. Changes to this policy</h2>
|
|
296
|
-
<p>We may update this policy from time to time. Material changes will be communicated through the site, and the "last updated" date will be revised.</p>
|
|
297
|
-
|
|
298
|
-
<h2>12. Contact us</h2>
|
|
299
|
-
<p>Questions or complaints? Contact NextBlock™ CMS at <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>. You may also contact the Commission d'accès à l'information du Québec or the Office of the Privacy Commissioner of Canada.</p>
|
|
300
|
-
$html$), 0);
|
|
301
|
-
|
|
302
|
-
-- ----- Privacy Policy (FR) -----
|
|
303
|
-
IF v_fr IS NOT NULL THEN
|
|
304
|
-
INSERT INTO public.pages (language_id, title, slug, status, meta_title, meta_description, translation_group_id)
|
|
305
|
-
VALUES (
|
|
306
|
-
v_fr, 'Politique de confidentialité', 'politique-de-confidentialite', 'published',
|
|
307
|
-
'Politique de confidentialité',
|
|
308
|
-
'Comment nous recueillons, utilisons, communiquons et protégeons vos renseignements personnels en vertu de la Loi 25, de la LPRPDE et de la LCAP.',
|
|
309
|
-
v_privacy_group
|
|
310
|
-
)
|
|
311
|
-
ON CONFLICT (language_id, slug) DO UPDATE
|
|
312
|
-
SET title = EXCLUDED.title, status = EXCLUDED.status,
|
|
313
|
-
meta_title = EXCLUDED.meta_title, meta_description = EXCLUDED.meta_description
|
|
314
|
-
RETURNING id INTO v_page_id;
|
|
315
|
-
|
|
316
|
-
DELETE FROM public.blocks WHERE page_id = v_page_id;
|
|
317
|
-
INSERT INTO public.blocks (page_id, language_id, block_type, content, "order")
|
|
318
|
-
VALUES (v_page_id, v_fr, 'text', jsonb_build_object('html_content', $html$
|
|
319
|
-
<h1>Politique de confidentialité</h1>
|
|
320
|
-
<p><em>Dernière mise à jour : 4 juin 2026</em></p>
|
|
321
|
-
<p>NextBlock™ CMS (« nous ») respecte votre vie privée et s'engage à protéger vos renseignements personnels conformément à la <em>Loi sur la protection des renseignements personnels dans le secteur privé</em> du Québec (Loi 25), à la <em>Loi sur la protection des renseignements personnels et les documents électroniques</em> (LPRPDE) et à la Loi canadienne anti-pourriel (LCAP).</p>
|
|
322
|
-
|
|
323
|
-
<h2>1. Responsable de la protection des renseignements personnels</h2>
|
|
324
|
-
<p>Notre responsable de la protection des renseignements personnels veille au respect des lois applicables. Vous pouvez le joindre à <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>.</p>
|
|
325
|
-
|
|
326
|
-
<h2>2. Renseignements que nous recueillons</h2>
|
|
327
|
-
<ul>
|
|
328
|
-
<li><strong>Renseignements de compte</strong> — nom, adresse courriel et identifiants lors de l'inscription.</li>
|
|
329
|
-
<li><strong>Données d'utilisation et d'appareil</strong> — recueillies uniquement avec votre consentement au moyen de technologies d'analyse.</li>
|
|
330
|
-
<li><strong>Communications</strong> — les messages que vous nous envoyez et vos préférences marketing.</li>
|
|
331
|
-
</ul>
|
|
332
|
-
|
|
333
|
-
<h2>3. Finalités et consentement</h2>
|
|
334
|
-
<p>Nous recueillons des renseignements personnels à des fins clairement déterminées : fournir et sécuriser nos services, communiquer avec vous et — uniquement avec votre consentement exprès — à des fins d'analyse et de marketing. Conformément à la Loi 25, les témoins et traceurs non essentiels demeurent désactivés tant que vous ne les avez pas acceptés, et vous pouvez retirer votre consentement en tout temps.</p>
|
|
335
|
-
|
|
336
|
-
<h2>4. Témoins et technologies de suivi</h2>
|
|
337
|
-
<p>Les témoins strictement nécessaires assurent le fonctionnement du site et ne requièrent aucun consentement. Les technologies d'analyse et de marketing ne sont chargées qu'<strong>après</strong> votre consentement explicite. Votre choix est enregistré afin de le respecter.</p>
|
|
338
|
-
|
|
339
|
-
<h2>5. Communication à des tiers</h2>
|
|
340
|
-
<p>Nous ne vendons pas vos renseignements personnels. Nous ne les communiquons qu'à des fournisseurs qui nous aident à exploiter la plateforme, sous obligation de confidentialité, ou lorsque la loi l'exige.</p>
|
|
341
|
-
|
|
342
|
-
<h2>6. Conservation</h2>
|
|
343
|
-
<p>Nous ne conservons les renseignements personnels que le temps nécessaire aux fins décrites ou exigé par la loi, après quoi ils sont détruits ou anonymisés de façon sécuritaire.</p>
|
|
344
|
-
|
|
345
|
-
<h2>7. Vos droits</h2>
|
|
346
|
-
<p>Sous réserve de la loi applicable, vous avez le droit d'accéder à vos renseignements, de les rectifier et de les supprimer, de retirer votre consentement, à la portabilité de vos données et d'être informé du traitement automatisé. Pour exercer ces droits, écrivez à <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>.</p>
|
|
347
|
-
|
|
348
|
-
<h2>8. Messages électroniques commerciaux (LCAP)</h2>
|
|
349
|
-
<p>Nous n'envoyons des messages électroniques commerciaux qu'avec votre consentement. Chaque message nous identifie et comporte un mécanisme de désabonnement fonctionnel que nous respectons rapidement.</p>
|
|
350
|
-
|
|
351
|
-
<h2>9. Mesures de sécurité</h2>
|
|
352
|
-
<p>Nous employons des mesures physiques, organisationnelles et technologiques appropriées — dont le chiffrement en transit et le contrôle des accès — pour protéger vos renseignements.</p>
|
|
353
|
-
|
|
354
|
-
<h2>10. Logiciel libre</h2>
|
|
355
|
-
<p>NextBlock™ CMS est un logiciel libre et à code source ouvert distribué sous la licence publique générale GNU Affero v3. Lorsque vous hébergez NextBlock vous-même, vous êtes l'exploitant responsable des renseignements personnels traités par votre propre instance, et la présente politique vous sert de point de départ adaptable à votre organisation.</p>
|
|
356
|
-
|
|
357
|
-
<h2>11. Modifications</h2>
|
|
358
|
-
<p>Nous pouvons mettre à jour cette politique. Les changements importants seront communiqués sur le site et la date de mise à jour sera révisée.</p>
|
|
359
|
-
|
|
360
|
-
<h2>12. Nous joindre</h2>
|
|
361
|
-
<p>Des questions ou des plaintes ? Contactez NextBlock™ CMS à <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>. Vous pouvez aussi vous adresser à la Commission d'accès à l'information du Québec.</p>
|
|
362
|
-
$html$), 0);
|
|
363
|
-
END IF;
|
|
364
|
-
|
|
365
|
-
-- ----- Terms of Service (EN) -- aligned with the AGPL-3.0 (LICENSE.md) -----
|
|
366
|
-
INSERT INTO public.pages (language_id, title, slug, status, meta_title, meta_description, translation_group_id)
|
|
367
|
-
VALUES (
|
|
368
|
-
v_en, 'Terms of Service', 'terms-of-service', 'published',
|
|
369
|
-
'Terms of Service',
|
|
370
|
-
'The terms governing your use of NextBlock™ CMS, free and open-source software licensed under the AGPL-3.0.',
|
|
371
|
-
v_terms_group
|
|
372
|
-
)
|
|
373
|
-
ON CONFLICT (language_id, slug) DO UPDATE
|
|
374
|
-
SET title = EXCLUDED.title, status = EXCLUDED.status,
|
|
375
|
-
meta_title = EXCLUDED.meta_title, meta_description = EXCLUDED.meta_description
|
|
376
|
-
RETURNING id INTO v_page_id;
|
|
377
|
-
|
|
378
|
-
DELETE FROM public.blocks WHERE page_id = v_page_id;
|
|
379
|
-
INSERT INTO public.blocks (page_id, language_id, block_type, content, "order")
|
|
380
|
-
VALUES (v_page_id, v_en, 'text', jsonb_build_object('html_content', $html$
|
|
381
|
-
<h1>Terms of Service</h1>
|
|
382
|
-
<p><em>Last updated: June 4, 2026</em></p>
|
|
383
|
-
|
|
384
|
-
<h2>1. Acceptance of terms</h2>
|
|
385
|
-
<p>By accessing or using NextBlock™ CMS and the services we provide (the "Services"), you agree to be bound by these Terms of Service. If you do not agree, do not use the Services.</p>
|
|
386
|
-
|
|
387
|
-
<h2>2. Free and open-source software</h2>
|
|
388
|
-
<p>NextBlock™ CMS is free, open-source software licensed under the <strong>GNU Affero General Public License, version 3 (AGPL-3.0)</strong> or, at your option, any later version. You are free to run, study, share, and modify the software under the terms of that license. A copy of the license is distributed with the software and is also available at <a href="https://www.gnu.org/licenses/agpl-3.0.html">gnu.org/licenses/agpl-3.0.html</a>.</p>
|
|
389
|
-
<p>Copyright © 2025 NextBlock™ CMS.</p>
|
|
390
|
-
|
|
391
|
-
<h2>3. Source code availability</h2>
|
|
392
|
-
<p>In accordance with section 13 of the AGPL-3.0, if you run a modified version of NextBlock™ CMS and make it available to users over a network, you must prominently offer those users access to the Corresponding Source of your modified version, free of charge, through a standard or customary means of facilitating copying of software.</p>
|
|
393
|
-
|
|
394
|
-
<h2>4. Trademarks</h2>
|
|
395
|
-
<p>The AGPL-3.0 grants broad rights to the software's source code but does <strong>not</strong> grant any rights to our trade names, trademarks, or service marks. "NextBlock™", the NextBlock™ CMS name, and associated logos remain our property and may not be used in a way that suggests endorsement or affiliation without our prior written permission.</p>
|
|
396
|
-
|
|
397
|
-
<h2>5. Accounts and acceptable use</h2>
|
|
398
|
-
<p>If you create an account, you are responsible for safeguarding your credentials and for all activity under your account, and you agree to notify us promptly of any unauthorized use. You agree not to misuse the Services, including by attempting to disrupt them, access them without authorization, or use them for unlawful purposes.</p>
|
|
399
|
-
|
|
400
|
-
<h2>6. No warranty</h2>
|
|
401
|
-
<p>As stated in section 15 of the AGPL-3.0, the software is provided "as is", without warranty of any kind, either expressed or implied, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the software is with you.</p>
|
|
402
|
-
|
|
403
|
-
<h2>7. Limitation of liability</h2>
|
|
404
|
-
<p>As stated in section 16 of the AGPL-3.0, and to the fullest extent permitted by applicable law, in no event will any copyright holder, or any other party who modifies or conveys the software, be liable to you for damages, including any general, special, incidental, or consequential damages arising out of the use or inability to use the software.</p>
|
|
405
|
-
|
|
406
|
-
<h2>8. Governing law</h2>
|
|
407
|
-
<p>These Terms are governed by the laws of the Province of Quebec and the federal laws of Canada applicable therein, without regard to conflict-of-law principles. Nothing in these Terms limits any mandatory consumer-protection rights you may have under those laws.</p>
|
|
408
|
-
|
|
409
|
-
<h2>9. Changes</h2>
|
|
410
|
-
<p>We may revise these Terms from time to time. Material changes will be communicated through the Services, and continued use of the Services after changes take effect constitutes acceptance of the revised Terms.</p>
|
|
411
|
-
|
|
412
|
-
<h2>10. Contact</h2>
|
|
413
|
-
<p>Questions about these Terms? Contact NextBlock™ CMS at <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>.</p>
|
|
414
|
-
$html$), 0);
|
|
415
|
-
|
|
416
|
-
-- ----- Terms of Service (FR) -- aligned with the AGPL-3.0 (LICENSE.md) -----
|
|
417
|
-
IF v_fr IS NOT NULL THEN
|
|
418
|
-
INSERT INTO public.pages (language_id, title, slug, status, meta_title, meta_description, translation_group_id)
|
|
419
|
-
VALUES (
|
|
420
|
-
v_fr, 'Conditions d''utilisation', 'conditions-utilisation', 'published',
|
|
421
|
-
'Conditions d''utilisation',
|
|
422
|
-
'Les conditions régissant votre utilisation de NextBlock™ CMS, un logiciel libre sous licence AGPL-3.0.',
|
|
423
|
-
v_terms_group
|
|
424
|
-
)
|
|
425
|
-
ON CONFLICT (language_id, slug) DO UPDATE
|
|
426
|
-
SET title = EXCLUDED.title, status = EXCLUDED.status,
|
|
427
|
-
meta_title = EXCLUDED.meta_title, meta_description = EXCLUDED.meta_description
|
|
428
|
-
RETURNING id INTO v_page_id;
|
|
429
|
-
|
|
430
|
-
DELETE FROM public.blocks WHERE page_id = v_page_id;
|
|
431
|
-
INSERT INTO public.blocks (page_id, language_id, block_type, content, "order")
|
|
432
|
-
VALUES (v_page_id, v_fr, 'text', jsonb_build_object('html_content', $html$
|
|
433
|
-
<h1>Conditions d'utilisation</h1>
|
|
434
|
-
<p><em>Dernière mise à jour : 4 juin 2026</em></p>
|
|
435
|
-
|
|
436
|
-
<h2>1. Acceptation des conditions</h2>
|
|
437
|
-
<p>En accédant à NextBlock™ CMS et aux services que nous fournissons (les « Services ») ou en les utilisant, vous acceptez d'être lié par les présentes conditions d'utilisation. Si vous n'êtes pas d'accord, n'utilisez pas les Services.</p>
|
|
438
|
-
|
|
439
|
-
<h2>2. Logiciel libre et à code source ouvert</h2>
|
|
440
|
-
<p>NextBlock™ CMS est un logiciel libre et à code source ouvert distribué sous la <strong>licence publique générale GNU Affero, version 3 (AGPL-3.0)</strong> ou, à votre choix, toute version ultérieure. Vous êtes libre d'exécuter, d'étudier, de partager et de modifier le logiciel selon les termes de cette licence. Une copie de la licence est fournie avec le logiciel et est aussi disponible à <a href="https://www.gnu.org/licenses/agpl-3.0.html">gnu.org/licenses/agpl-3.0.html</a>.</p>
|
|
441
|
-
<p>Droit d'auteur © 2025 NextBlock™ CMS.</p>
|
|
442
|
-
|
|
443
|
-
<h2>3. Disponibilité du code source</h2>
|
|
444
|
-
<p>Conformément à l'article 13 de l'AGPL-3.0, si vous exploitez une version modifiée de NextBlock™ CMS et la rendez accessible à des utilisateurs sur un réseau, vous devez offrir clairement à ces utilisateurs l'accès au code source correspondant de votre version modifiée, gratuitement, par un moyen usuel de copie de logiciels.</p>
|
|
445
|
-
|
|
446
|
-
<h2>4. Marques de commerce</h2>
|
|
447
|
-
<p>L'AGPL-3.0 accorde de larges droits sur le code source du logiciel, mais <strong>n'accorde aucun droit</strong> sur nos noms commerciaux, marques de commerce ou marques de service. « NextBlock™ », le nom NextBlock™ CMS et les logos associés demeurent notre propriété et ne peuvent être utilisés d'une manière laissant entendre une approbation ou une affiliation sans notre autorisation écrite préalable.</p>
|
|
448
|
-
|
|
449
|
-
<h2>5. Comptes et utilisation acceptable</h2>
|
|
450
|
-
<p>Si vous créez un compte, vous êtes responsable de la protection de vos identifiants et de toute activité effectuée à partir de votre compte, et vous vous engagez à nous aviser rapidement de toute utilisation non autorisée. Vous vous engagez à ne pas détourner les Services, notamment en tentant de les perturber, d'y accéder sans autorisation ou de les utiliser à des fins illégales.</p>
|
|
451
|
-
|
|
452
|
-
<h2>6. Absence de garantie</h2>
|
|
453
|
-
<p>Comme l'énonce l'article 15 de l'AGPL-3.0, le logiciel est fourni « tel quel », sans garantie d'aucune sorte, expresse ou implicite, y compris, sans s'y limiter, les garanties implicites de qualité marchande et d'adéquation à un usage particulier. Vous assumez l'entièreté du risque quant à la qualité et au rendement du logiciel.</p>
|
|
454
|
-
|
|
455
|
-
<h2>7. Limitation de responsabilité</h2>
|
|
456
|
-
<p>Comme l'énonce l'article 16 de l'AGPL-3.0, et dans toute la mesure permise par la loi applicable, en aucun cas un titulaire de droits d'auteur ou toute autre partie qui modifie ou transmet le logiciel ne saurait être tenu responsable envers vous de dommages, y compris tout dommage général, spécial, accessoire ou consécutif découlant de l'utilisation ou de l'impossibilité d'utiliser le logiciel.</p>
|
|
457
|
-
|
|
458
|
-
<h2>8. Droit applicable</h2>
|
|
459
|
-
<p>Les présentes conditions sont régies par les lois de la province de Québec et les lois fédérales du Canada qui y sont applicables, sans égard aux règles de conflit de lois. Rien dans les présentes conditions ne limite les droits impératifs de protection du consommateur dont vous pourriez bénéficier en vertu de ces lois.</p>
|
|
460
|
-
|
|
461
|
-
<h2>9. Modifications</h2>
|
|
462
|
-
<p>Nous pouvons réviser ces conditions de temps à autre. Les changements importants seront communiqués au moyen des Services, et l'utilisation continue des Services après leur entrée en vigueur vaut acceptation.</p>
|
|
463
|
-
|
|
464
|
-
<h2>10. Nous joindre</h2>
|
|
465
|
-
<p>Des questions sur ces conditions ? Contactez NextBlock™ CMS à <a href="mailto:privacy@nextblock.dev">privacy@nextblock.dev</a>.</p>
|
|
466
|
-
$html$), 0);
|
|
467
|
-
END IF;
|
|
468
|
-
|
|
469
|
-
RAISE NOTICE 'Seeded privacy-policy and terms-of-service pages.';
|
|
470
|
-
END;
|
|
471
|
-
$seed$;
|
|
472
|
-
|
|
473
|
-
-- ---------------------------------------------------------------------------
|
|
474
|
-
-- 7. UI translations introduced with this feature
|
|
475
|
-
-- ---------------------------------------------------------------------------
|
|
476
|
-
INSERT INTO public.translations (key, translations) VALUES
|
|
477
|
-
('remember_this_device', '{"en": "Remember this device", "fr": "Se souvenir de cet appareil"}'::jsonb)
|
|
478
|
-
ON CONFLICT (key) DO UPDATE
|
|
479
|
-
SET translations = EXCLUDED.translations;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
-- 00000000000028_clear_advisor_warnings.sql
|
|
2
|
-
-- Resolve Supabase Advisor (database linter) warnings without changing application
|
|
3
|
-
-- behaviour. Every statement is idempotent and safe to re-run.
|
|
4
|
-
--
|
|
5
|
-
-- 1. 0011 function_search_path_mutable
|
|
6
|
-
-- public.handle_ucp_cart_sessions_update() had no pinned search_path.
|
|
7
|
-
-- 2. 0029 authenticated_security_definer_function_executable
|
|
8
|
-
-- public.duplicate_block_definition(uuid) ran as SECURITY DEFINER and was
|
|
9
|
-
-- callable by every signed-in user. RLS + per-action grants already enforce
|
|
10
|
-
-- ADMIN/WRITER, so it is switched to SECURITY INVOKER (it also keeps its own
|
|
11
|
-
-- explicit role check). ADMIN/WRITER behaviour is unchanged.
|
|
12
|
-
-- 3/4. 0006 multiple_permissive_policies
|
|
13
|
-
-- public.categories and public.product_categories each had a FOR ALL
|
|
14
|
-
-- "Admin can manage ..." policy that overlapped the "Public can view ..."
|
|
15
|
-
-- SELECT policy for the authenticated role. The FOR ALL policy is split into
|
|
16
|
-
-- INSERT/UPDATE/DELETE so a SELECT is evaluated against a single permissive
|
|
17
|
-
-- policy while admin write access is preserved.
|
|
18
|
-
--
|
|
19
|
-
-- (The leaked-password and MFA-options advisor items are Auth dashboard settings,
|
|
20
|
-
-- not schema, and are intentionally not addressed here.)
|
|
21
|
-
|
|
22
|
-
-- ---------------------------------------------------------------------------
|
|
23
|
-
-- 1. Pin search_path on the UCP cart-session updated_at trigger function.
|
|
24
|
-
-- The body only calls now() (pg_catalog, always implicitly searched), so an
|
|
25
|
-
-- empty search_path is safe and matches the convention already used by
|
|
26
|
-
-- public.is_valid_custom_block_fields (migration 00000000000023).
|
|
27
|
-
-- ---------------------------------------------------------------------------
|
|
28
|
-
ALTER FUNCTION public.handle_ucp_cart_sessions_update() SET search_path = '';
|
|
29
|
-
|
|
30
|
-
-- ---------------------------------------------------------------------------
|
|
31
|
-
-- 2. duplicate_block_definition: SECURITY DEFINER -> SECURITY INVOKER.
|
|
32
|
-
-- The function still raises 42501 for non-ADMIN/WRITER callers, and the
|
|
33
|
-
-- underlying SELECT/INSERT are already gated by custom_block_definitions RLS
|
|
34
|
-
-- plus the authenticated SELECT/INSERT grants, so the function no longer needs
|
|
35
|
-
-- to run with the definer's elevated privileges.
|
|
36
|
-
-- ---------------------------------------------------------------------------
|
|
37
|
-
ALTER FUNCTION public.duplicate_block_definition(uuid) SECURITY INVOKER;
|
|
38
|
-
|
|
39
|
-
-- ---------------------------------------------------------------------------
|
|
40
|
-
-- 3. categories: split the FOR ALL admin policy so SELECT has one permissive
|
|
41
|
-
-- policy (the public-read policy). Admin reads still flow through that policy
|
|
42
|
-
-- (USING true); admin writes are preserved via the per-action policies below.
|
|
43
|
-
-- ---------------------------------------------------------------------------
|
|
44
|
-
DROP POLICY IF EXISTS "Admin can manage categories" ON public.categories;
|
|
45
|
-
|
|
46
|
-
DROP POLICY IF EXISTS "Admin can insert categories" ON public.categories;
|
|
47
|
-
CREATE POLICY "Admin can insert categories"
|
|
48
|
-
ON public.categories
|
|
49
|
-
FOR INSERT
|
|
50
|
-
TO authenticated
|
|
51
|
-
WITH CHECK ((SELECT public.is_admin()) IS TRUE);
|
|
52
|
-
|
|
53
|
-
DROP POLICY IF EXISTS "Admin can update categories" ON public.categories;
|
|
54
|
-
CREATE POLICY "Admin can update categories"
|
|
55
|
-
ON public.categories
|
|
56
|
-
FOR UPDATE
|
|
57
|
-
TO authenticated
|
|
58
|
-
USING ((SELECT public.is_admin()) IS TRUE)
|
|
59
|
-
WITH CHECK ((SELECT public.is_admin()) IS TRUE);
|
|
60
|
-
|
|
61
|
-
DROP POLICY IF EXISTS "Admin can delete categories" ON public.categories;
|
|
62
|
-
CREATE POLICY "Admin can delete categories"
|
|
63
|
-
ON public.categories
|
|
64
|
-
FOR DELETE
|
|
65
|
-
TO authenticated
|
|
66
|
-
USING ((SELECT public.is_admin()) IS TRUE);
|
|
67
|
-
|
|
68
|
-
-- ---------------------------------------------------------------------------
|
|
69
|
-
-- 4. product_categories: same split as categories.
|
|
70
|
-
-- ---------------------------------------------------------------------------
|
|
71
|
-
DROP POLICY IF EXISTS "Admin can manage product_categories" ON public.product_categories;
|
|
72
|
-
|
|
73
|
-
DROP POLICY IF EXISTS "Admin can insert product_categories" ON public.product_categories;
|
|
74
|
-
CREATE POLICY "Admin can insert product_categories"
|
|
75
|
-
ON public.product_categories
|
|
76
|
-
FOR INSERT
|
|
77
|
-
TO authenticated
|
|
78
|
-
WITH CHECK ((SELECT public.is_admin()) IS TRUE);
|
|
79
|
-
|
|
80
|
-
DROP POLICY IF EXISTS "Admin can update product_categories" ON public.product_categories;
|
|
81
|
-
CREATE POLICY "Admin can update product_categories"
|
|
82
|
-
ON public.product_categories
|
|
83
|
-
FOR UPDATE
|
|
84
|
-
TO authenticated
|
|
85
|
-
USING ((SELECT public.is_admin()) IS TRUE)
|
|
86
|
-
WITH CHECK ((SELECT public.is_admin()) IS TRUE);
|
|
87
|
-
|
|
88
|
-
DROP POLICY IF EXISTS "Admin can delete product_categories" ON public.product_categories;
|
|
89
|
-
CREATE POLICY "Admin can delete product_categories"
|
|
90
|
-
ON public.product_categories
|
|
91
|
-
FOR DELETE
|
|
92
|
-
TO authenticated
|
|
93
|
-
USING ((SELECT public.is_admin()) IS TRUE);
|