blob: 9e5899e3700b849552dc6e4b014782659c96e3b7 [file] [log] [blame]
<?php
require_once(__DIR__."/../core.php");
if (!secondFactor::isAvailable() || security::userType() !== security::UNKNOWN || !isset($_SESSION["firstfactorid"]) || !secondFactor::isEnabled($_SESSION["firstfactorid"])) {
api::error();
}
$input = api::inputJson();
if ($input === false || !isset($input["code"])) api::error();
$code = (string)$input["code"];
if (secondFactor::completeCodeChallenge($code)) {
api::write(["status" => "ok"]);
} else {
api::write(["status" => "wrongCode"]);
}