blob: 7dd504ee087d9c2f822d07ec45ef83f4dc64070c [file] [log] [blame]
<?php
require_once(__DIR__."/../core.php");
if (!secondFactor::isAvailable() || security::userType() !== security::UNKNOWN || !isset($_SESSION["firstfactorid"]) || !secondFactor::isEnabled($_SESSION["firstfactorid"]) || !secondFactor::hasSecurityKeys($_SESSION["firstfactorid"]) || $_SERVER['REQUEST_METHOD'] !== "POST") {
api::error();
}
try {
$result = secondFactor::createValidationChallenge();
} catch (Throwable $e) {
api::error($conf['debug'] ? $e->getMessage() : null);
}
if (isset($result->publicKey)) $result->publicKey->rpId = ($conf["secondFactor"]["origin"] ?? null);
api::write($result);