<?php
include_once "../config/database.php";
include_once '../security/csrf.php';
include_once "../resources/manageusers.php";
include_once "../resources/EncryptDecrypt.php";

$csrf_token = $_POST['csrf_token'];
validate_csrf_request($csrf_token);

if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["company_id"])) {
    $companyId = intval($_POST["company_id"]);

    $object = new ManageUsers();
    $rules = $object->GetPasswordRules($companyId);

    if ($rules) {
        echo json_encode(["success" => true, "rules" => $rules]);
    } else {
        echo json_encode(["success" => false, "message" => "Failed to fetch rules"]);
    }
} else {
    echo json_encode(["success" => false, "message" => "Invalid request"]);
}
?>
