import { db } from '@/lib/db' import { redirect } from 'next/navigation' import { NextRequest } from 'next/server' export async function GET( _request: NextRequest, { params, }: { params: { token: string } } ) { const { token } = params const user = await db.user.findFirst({ where: { ActivationToken: { some: { AND: [ { activationDate: null, }, { createdAt: { gt: new Date(Date.now() - 24 * 60 * 60 * 1000), // 24 hours ago }, }, { token }, ], }, }, }, }) if (!user) { throw new Error('Token is invalid or expired') } const userUpdate = await db.user.update({ where: { id: user.id, }, data: { emailVerified: new Date(Date.now()), }, }) const actiaction = await db.activationToken.update({ where: { token, }, data: { activationDate: new Date(), }, }) redirect('/verify') }