Просмотр исходного кода

fix: use service role client for oauth_states insert #17

Claude 5 месяцев назад
Родитель
Сommit
585b6f76a3
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      supabase/functions/oauth-woocommerce/index.ts

+ 4 - 1
supabase/functions/oauth-woocommerce/index.ts

@@ -176,8 +176,11 @@ serve(async (req) => {
       // Generate state for CSRF protection
       // Generate state for CSRF protection
       const state = crypto.randomUUID()
       const state = crypto.randomUUID()
 
 
+      // Create Supabase admin client for storing state (requires service role)
+      const supabaseAdmin = createClient(supabaseUrl, supabaseServiceKey)
+
       // Store state in database
       // Store state in database
-      const { error: stateError } = await supabase
+      const { error: stateError } = await supabaseAdmin
         .from('oauth_states')
         .from('oauth_states')
         .insert({
         .insert({
           state,
           state,