<?php

include_once dirname(__DIR__, 2) . "/config/dbcon.php";
include_once dirname(__DIR__, 2) . "/helpers/api_helper.php";

include_once dirname(__DIR__, 2) . "/firebase/firebase_init.php";

try {
    if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
        sendResponse(405, "Method Not Allowed");
    }

    $input = json_decode(file_get_contents("php://input"), true);
    $email = $input['email'] ?? null;

    if (empty($email)) {
        sendResponse(400, "Email is required");
    }


    $auth->sendEmailVerificationLink($email);


    sendResponse(200, "Verification email resent successfully");

} catch (Exception $e) {
    sendResponse(500, $e->getMessage());
}
