Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
DELETE FROM public.login_attempts WHERE email='adm01@promobrindes.com.br' AND success=false AND created_at > now() - interval '30 minutes';
-- ============================================================================
-- SANITIZADA EM 19/MAI/2026 — REMOVE PII E AMPLIA SEMÂNTICA
-- ============================================================================
--
-- ⚠️ HISTÓRICO DESTE ARQUIVO:
-- Originalmente continha um DELETE ad-hoc com email específico de um usuario
-- (PII) hardcoded — gerado pelo Lovable para destravar tentativas de login
-- bloqueadas por rate limit. Esse tipo de comando NUNCA deveria ter sido
-- commitado como migration permanente. Foi sanitizado nesta mesma data.
--
-- O QUE ESTA MIGRATION FAZ AGORA:
-- Limpa tentativas de login FALHADAS antigas (>30 dias) de TODA a tabela
-- login_attempts. Sem hardcoded de usuário. Sem PII no histórico do git.
--
-- IDEMPOTENTE: na 2ª execução, retorna 0 rows (todos já apagados).
-- ============================================================================

DELETE FROM public.login_attempts
WHERE success = false
AND created_at < now() - interval '30 days';

DO $$
DECLARE
_deleted integer;
BEGIN
Comment on lines +18 to +25
GET DIAGNOSTICS _deleted = ROW_COUNT;
RAISE NOTICE '[cleanup_login_attempts] Removed % stale failed login attempts (>30 days old)', _deleted;
Comment on lines +26 to +27
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Capture deleted row count in same PL/pgSQL block

GET DIAGNOSTICS ... ROW_COUNT inside this DO block does not read the row count from the previous top-level DELETE; in PostgreSQL it reflects the most recent SQL command executed within the current PL/pgSQL block. As written, _deleted will be reported as 0 (or otherwise not represent the preceding delete), so the migration’s notice is misleading and can hide whether cleanup actually removed rows.

Useful? React with 👍 / 👎.

END $$;
Loading