60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
const axios = require('axios');
|
|
|
|
const SUPABASE_URL = 'https://yuanqfswhberkoevtmfr.supabase.co';
|
|
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inl1YW5xZnN3aGJlcmtvZXZ0bWZyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ5NTQzNjksImV4cCI6MjA3MDUzMDM2OX0.g8Fm4XAvtX46zifBZnYVH4tVuQkqUH6Ia9CXQj4DztQ';
|
|
|
|
async function main() {
|
|
try {
|
|
console.log('🔐 Fazendo login como admin...');
|
|
|
|
const loginResponse = await axios.post(
|
|
`${SUPABASE_URL}/auth/v1/token?grant_type=password`,
|
|
{
|
|
email: 'riseup@popcode.com.br',
|
|
password: 'riseup'
|
|
},
|
|
{
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'apikey': SUPABASE_ANON_KEY
|
|
}
|
|
}
|
|
);
|
|
|
|
const adminToken = loginResponse.data.access_token;
|
|
console.log('✅ Login realizado\n');
|
|
|
|
console.log('👤 Buscando dados de Aurora na tabela patients...');
|
|
|
|
const patientsResponse = await axios.get(
|
|
`${SUPABASE_URL}/rest/v1/patients?email=eq.aurora-nascimento94@gmx.com`,
|
|
{
|
|
headers: {
|
|
'apikey': SUPABASE_ANON_KEY,
|
|
'Authorization': `Bearer ${adminToken}`
|
|
}
|
|
}
|
|
);
|
|
|
|
if (patientsResponse.data.length > 0) {
|
|
const patient = patientsResponse.data[0];
|
|
console.log('✅ Paciente encontrada!\n');
|
|
console.log('📋 DADOS DA AURORA:\n');
|
|
console.log('User ID (auth):', patient.id);
|
|
console.log('Patient ID:', patient.id); // Em patients, o id é o mesmo do auth
|
|
console.log('Nome:', patient.full_name);
|
|
console.log('Email:', patient.email);
|
|
console.log('CPF:', patient.cpf);
|
|
console.log('Telefone:', patient.phone_mobile);
|
|
console.log('\n📄 Dados completos:', JSON.stringify(patient, null, 2));
|
|
} else {
|
|
console.log('❌ Paciente não encontrada na tabela patients');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Erro:', error.response?.data || error.message);
|
|
}
|
|
}
|
|
|
|
main();
|