caterium-app/ops/sql/SUPABASE-V17.7.4-PASSWORD-SECURITY.sql
2026-09-11 10:09:45 +03:00

16 lines
557 B
PL/PgSQL

-- Caterium v17.7.4: move mandatory temporary-password state to server-controlled app metadata.
-- Legacy user_metadata is client-editable and must not be trusted for this security state.
begin;
update auth.users
set raw_app_meta_data = coalesce(raw_app_meta_data, '{}'::jsonb)
|| jsonb_build_object(
'must_change_password', true,
'password_policy_version', 'v1774'
)
where lower(coalesce(raw_user_meta_data->>'must_change_password', '')) = 'true'
and lower(coalesce(raw_app_meta_data->>'must_change_password', 'false')) <> 'true';
commit;