import db from '@admin/db' import { verification } from '@admin/db/schema' import { and, eq, gt } from 'drizzle-orm' import { connection } from 'next/server' export async function isResetPasswordTokenValid(token: string): Promise { // `searchParams` resolves during the prerender, so the expiry comparison // below must wait for the real request or Next rejects the `new Date()`. await connection() const rows = await db .select({ id: verification.id }) .from(verification) .where( and( eq(verification.identifier, `reset-password:${token}`), gt(verification.expiresAt, new Date()) ) ) .limit(1) return rows.length > 0 }