import { NextResponse } from 'next/server'
import { auth, getSanitizedHeaders } from '@/lib/auth'
import { prisma } from '@innungsapp/shared'

export async function POST() {
  const session = await auth.api.getSession({ headers: await getSanitizedHeaders() })
  if (!session?.user?.id) {
    return NextResponse.json({ error: 'Nicht eingeloggt' }, { status: 401 })
  }

  await prisma.user.update({
    where: { id: session.user.id },
    data: { mustChangePassword: false },
  })

  return NextResponse.json({ success: true })
}
