Fix hash_session_ip function

This commit is contained in:
gpt-engineer-app[bot]
2025-11-01 20:52:45 +00:00
parent 0aaae94ef6
commit 9ba3e204f6
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
-- Fix hash_session_ip to use pgcrypto from extensions schema
CREATE OR REPLACE FUNCTION public.hash_session_ip(session_ip inet)
RETURNS text
LANGUAGE plpgsql
IMMUTABLE
SET search_path = 'public', 'extensions'
AS $$
BEGIN
-- Return last 8 chars of SHA256 hash with asterisks prefix for privacy
RETURN '****' || RIGHT(encode(digest(session_ip::text || 'session_salt_2025', 'sha256'), 'hex'), 8);
END;
$$;