import { verifyOtpAndResetPassword } from '@/modules/password-reset/services/password-reset.service';
import type { AppContext } from '@/types/hono';
import type { PasswordResetVerifyInput } from '@repo/api-contract';

export async function verifyPasswordResetHandler(c: AppContext) {
  const payload = c.req.valid('json' as never) as PasswordResetVerifyInput;

  const ip = c.req.header('x-forwarded-for') || c.req.header('cf-connecting-ip') || 'unknown';
  const userAgent = c.req.header('user-agent');

  const result = await verifyOtpAndResetPassword(payload, ip, userAgent);
  return c.json(result, 200);
}
