-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirm_users.js
More file actions
71 lines (56 loc) · 2.3 KB
/
confirm_users.js
File metadata and controls
71 lines (56 loc) · 2.3 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
67
68
69
70
71
// 이메일 인증 완료 처리 스크립트
// 실행: node confirm_users.js
const { createClient } = require('@supabase/supabase-js');
const SUPABASE_URL = 'https://erwynjouxmmontzhezuj.supabase.co';
const SUPABASE_SERVICE_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImVyd3luam91eG1tb250emhlenVqIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc1NjE3NDM0MSwiZXhwIjoyMDcxNzUwMzQxfQ.AYKKTDTx7_YPyAH-M35C0D1VzQDOTxRZBKJRPBYpUMw';
// Service Role 키로 Supabase 클라이언트 생성
const supabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_KEY, {
auth: {
autoRefreshToken: false,
persistSession: false
}
});
async function confirmUsers() {
try {
console.log('사용자 목록 조회 중...');
// Admin API를 사용하여 사용자 목록 조회
const { data: users, error: listError } = await supabase.auth.admin.listUsers();
if (listError) {
console.error('사용자 목록 조회 실패:', listError);
return;
}
console.log(`총 ${users.users.length}명의 사용자를 찾았습니다.`);
// test@billage.com과 admin@billage.com 계정 찾기
const testEmails = ['test@billage.com', 'admin@billage.com'];
const targetUsers = users.users.filter(user => testEmails.includes(user.email));
console.log(`대상 사용자: ${targetUsers.length}명`);
for (const user of targetUsers) {
console.log(`\n처리 중: ${user.email}`);
// 이메일 인증 완료 처리
const { data, error } = await supabase.auth.admin.updateUserById(
user.id,
{
email_confirm: true,
user_metadata: {
...user.user_metadata,
email_verified: true
}
}
);
if (error) {
console.error(` ❌ 실패: ${error.message}`);
} else {
console.log(` ✅ 성공: 이메일 인증 완료`);
console.log(` - ID: ${user.id}`);
console.log(` - Email: ${user.email}`);
console.log(` - Confirmed: ${data.user.email_confirmed_at ? '예' : '아니오'}`);
}
}
console.log('\n처리 완료!');
console.log('이제 앱에서 로그인할 수 있습니다.');
} catch (error) {
console.error('오류 발생:', error);
}
}
// 스크립트 실행
confirmUsers();