-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcheck-user-data.js
More file actions
66 lines (60 loc) · 1.88 KB
/
check-user-data.js
File metadata and controls
66 lines (60 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 检查用户在所有表中的数据
const { createClient } = require('@supabase/supabase-js');
require('dotenv').config({ path: '.env.local' });
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.SUPABASE_SERVICE_ROLE_KEY,
{ auth: { autoRefreshToken: false, persistSession: false } }
);
const userId = 'ca9912fb-0616-4706-a823-48f6cdbfb7f7';
const tables = [
'user_profiles',
'user_pdfs',
'pdf_conversations',
'conversation_messages',
'user_quotas',
'quota_usage',
'quota_operations',
'user_sessions',
'user_security_log',
];
(async () => {
console.log('=== 检查用户数据残留 ===');
console.log('用户 ID:', userId);
console.log('用户邮箱: 1804491927@qq.com');
console.log('');
for (const table of tables) {
try {
const { data, error, count } = await supabase
.from(table)
.select('*', { count: 'exact', head: true })
.eq('user_id', userId);
if (error) {
console.log(`❌ ${table}: ${error.message}`);
} else if (count > 0) {
console.log(`⚠️ ${table}: ${count} 条数据`);
} else {
console.log(`✓ ${table}: 无数据`);
}
} catch (e) {
console.log(`❌ ${table}: ${e.message}`);
}
}
// 检查 auth.users
console.log('');
console.log('=== 检查 auth.users ===');
const { data: authUsers, error: listError } = await supabase.auth.admin.listUsers();
if (!listError) {
const user = authUsers.users.find(u => u.id === userId);
if (user) {
console.log('⚠️ auth.users: 用户存在');
console.log(' 邮箱:', user.email);
console.log(' 创建时间:', user.created_at);
console.log(' 邮箱验证:', user.email_confirmed_at);
} else {
console.log('✓ auth.users: 用户不存在');
}
} else {
console.log('❌ 无法查询 auth.users:', listError.message);
}
})();