fix(auth,capa): restore auth callback, fix CAPA status update
- auth callback: remove debug redirect, handle both code (PKCE) and token_hash+type (recovery/magic link) flows correctly - capa PATCH: use admin client to bypass RLS for status updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WMymkhHZiaYZtUeH9MEHZQ
This commit is contained in:
@@ -2,6 +2,7 @@ export const dynamic = 'force-dynamic'
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { createClient } from '@/lib/supabase/server'
|
||||
import { createAdminClient } from '@/lib/supabase/admin'
|
||||
|
||||
export async function GET(
|
||||
_: NextRequest,
|
||||
@@ -74,7 +75,8 @@ export async function PATCH(
|
||||
update.completed_at = new Date().toISOString()
|
||||
}
|
||||
|
||||
const { error } = await supabase
|
||||
const admin = createAdminClient()
|
||||
const { error } = await admin
|
||||
.from('capa_actions')
|
||||
.update(update)
|
||||
.eq('id', id)
|
||||
|
||||
@@ -45,7 +45,7 @@ export async function POST(request: NextRequest) {
|
||||
const body = await request.json()
|
||||
const { incident_id, description, owner_user_id, department, due_date, priority, root_cause_ref } = body
|
||||
|
||||
if (!incident_id || !description || !owner_user_id || !department || !due_date)
|
||||
if (!incident_id || !description || !owner_user_id || !due_date)
|
||||
return NextResponse.json({ error: 'Missing required fields' }, { status: 422 })
|
||||
|
||||
const { data: capa, error } = await supabase
|
||||
@@ -54,7 +54,7 @@ export async function POST(request: NextRequest) {
|
||||
incident_id,
|
||||
description,
|
||||
owner_user_id,
|
||||
department,
|
||||
department: department || '',
|
||||
due_date,
|
||||
priority: priority ?? 'med',
|
||||
root_cause_ref: root_cause_ref ?? null,
|
||||
|
||||
Reference in New Issue
Block a user