riseup-squad18/MEDICONNECT 2/scripts/deletar-usuarios-teste.js
2025-10-07 14:53:47 -03:00

78 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import fetch from "node-fetch";
const SUPABASE_URL = "https://yuanqfswhberkoevtmfr.supabase.co";
const SUPABASE_ANON_KEY =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inl1YW5xZnN3aGJlcmtvZXZ0bWZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ5NTQzNjksImV4cCI6MjA3MDUzMDM2OX0.g8Fm4XAvtX46zifBZnYVH4tVuQkqUH6Ia9CXQj4DztQ";
console.log("\n🗑 DELETAR USUÁRIOS DE TESTE\n");
console.log(
"❌ ATENÇÃO: A API pública do Supabase não permite deletar usuários!"
);
console.log("");
console.log("Para deletar usuários de teste, você precisa:");
console.log("");
console.log("1⃣ Acessar o Dashboard do Supabase:");
console.log(
" https://app.supabase.com/project/yuanqfswhberkoevtmfr/auth/users"
);
console.log("");
console.log('2⃣ Na aba "Authentication" → "Users"');
console.log("");
console.log("3⃣ Buscar pelos usuários de teste e deletar manualmente:");
console.log(' - Emails com "pacienteteste" ou "teste"');
console.log(" - testefinal@gmail.com");
console.log(" - teste1759356178698@gmail.com");
console.log("");
console.log("📋 Listando usuários de teste nos registros de pacientes...\n");
async function listarPacientesTeste() {
try {
const response = await fetch(
`${SUPABASE_URL}/rest/v1/patients?select=id,full_name,email&email=ilike.*teste*`,
{
headers: {
apikey: SUPABASE_ANON_KEY,
"Content-Type": "application/json",
},
}
);
if (response.ok) {
const pacientes = await response.json();
if (pacientes.length === 0) {
console.log(
"✅ Nenhum paciente de teste encontrado na tabela patients\n"
);
} else {
console.log(
`📊 ${pacientes.length} paciente(s) de teste encontrado(s):\n`
);
pacientes.forEach((p, index) => {
console.log(`${index + 1}. ${p.full_name || "Sem nome"}`);
console.log(` Email: ${p.email}`);
console.log(` ID: ${p.id}\n`);
});
console.log(
" Para deletar esses registros de pacientes, você pode:"
);
console.log(
' - Deletar via Dashboard do Supabase na tabela "patients"'
);
console.log(
" - Ou criar um Edge Function com permissões de service_role\n"
);
}
} else {
console.log("❌ Erro ao listar pacientes:", response.status);
const error = await response.text();
console.log(error);
}
} catch (error) {
console.error("❌ Erro:", error.message);
}
}
listarPacientesTeste();