-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-microsoft-config.js
More file actions
98 lines (79 loc) · 3.48 KB
/
Copy pathdebug-microsoft-config.js
File metadata and controls
98 lines (79 loc) · 3.48 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Debug script to check and set Microsoft configuration in Supabase
// Run with: node debug-microsoft-config.js
import { createClient } from '@supabase/supabase-js';
// You'll need to replace these with your actual Supabase URL and key
const supabaseUrl = process.env.VITE_SUPABASE_URL || 'YOUR_SUPABASE_URL';
const supabaseKey = process.env.VITE_SUPABASE_ANON_KEY || 'YOUR_SUPABASE_KEY';
if (!supabaseUrl || !supabaseKey || supabaseUrl === 'YOUR_SUPABASE_URL') {
console.error('❌ Please set VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY environment variables');
process.exit(1);
}
const supabase = createClient(supabaseUrl, supabaseKey);
async function checkAndSetMicrosoftConfig() {
console.log('🔍 Checking Microsoft configuration in database...');
try {
// First, check if the app_configurations table exists and what's in it
const { data: existing, error: fetchError } = await supabase
.from('app_configurations')
.select('*')
.eq('key', 'oauth_settings');
console.log('📊 Current app_configurations table content:');
console.log('Data:', existing);
console.log('Error:', fetchError);
if (fetchError) {
console.log('❌ Error reading from app_configurations table:', fetchError);
// If table doesn't exist, try to create it
console.log('🔧 Attempting to create app_configurations table...');
const { error: createError } = await supabase.rpc('create_app_configurations_table');
console.log('Create table result:', createError);
}
// Check specifically for oauth_settings
if (!existing || existing.length === 0) {
console.log('⚡ No oauth_settings found, creating new record...');
// Example Microsoft Client ID (replace with real one)
const exampleClientId = 'your-microsoft-client-id-here';
const { data: inserted, error: insertError } = await supabase
.from('app_configurations')
.insert([
{
key: 'oauth_settings',
microsoft_client_id: exampleClientId,
created_at: new Date().toISOString(),
updated_at: new Date().toISOString()
}
])
.select();
console.log('📝 Insert result:');
console.log('Data:', inserted);
console.log('Error:', insertError);
if (insertError) {
console.log('❌ Failed to insert oauth_settings:', insertError);
} else {
console.log('✅ Successfully created oauth_settings record');
}
} else {
console.log('✅ Found existing oauth_settings:', existing[0]);
if (existing[0].microsoft_client_id) {
console.log('✅ Microsoft Client ID is configured:', existing[0].microsoft_client_id.substring(0, 8) + '...');
} else {
console.log('❌ Microsoft Client ID is not set in the record');
// Update with example client ID
const exampleClientId = 'your-microsoft-client-id-here';
const { data: updated, error: updateError } = await supabase
.from('app_configurations')
.update({
microsoft_client_id: exampleClientId,
updated_at: new Date().toISOString()
})
.eq('key', 'oauth_settings')
.select();
console.log('📝 Update result:');
console.log('Data:', updated);
console.log('Error:', updateError);
}
}
} catch (error) {
console.error('❌ Script error:', error);
}
}
checkAndSetMicrosoftConfig();