Files
accounted/app/api/extensions/arcim-migration/cleanup/cron/route.ts
T
Mattsson f7f40c04e4 fix: return provider OAuth callbacks to the initiating brand domain (#2305)
* fix: hand provider OAuth callbacks back to initiating brand

* fix: encrypt provider OAuth handoff payloads

* fix: purge expired provider OAuth handoffs
2026-09-05 13:35:11 +02:00

19 lines
702 B
TypeScript

import { NextResponse } from 'next/server'
import { withCronContext } from '@/lib/api/with-cron-context'
import { createServiceClient } from '@/lib/supabase/server'
// Purge abandoned OAuth states and handoffs even when their consent is retained.
export const GET = withCronContext('cron.provider_oauth_cleanup', async (_request, ctx) => {
const supabase = createServiceClient()
const { count, error } = await supabase
.from('provider_otc')
.delete({ count: 'exact' })
.lte('expires_at', new Date().toISOString())
if (error) throw error
const deleted = count ?? 0
ctx.log.info('provider OAuth cleanup summary', { deleted })
return NextResponse.json({ data: { deleted } })
})