Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | require_once(__DIR__."/../core.php"); |
| 3 | |
| 4 | if (!secondFactor::isAvailable() || security::userType() !== security::UNKNOWN || !isset($_SESSION["firstfactorid"]) || !secondFactor::isEnabled($_SESSION["firstfactorid"])) { |
| 5 | api::error(); |
| 6 | } |
| 7 | |
| 8 | $input = api::inputJson(); |
| 9 | if ($input === false || !isset($input["code"])) api::error(); |
| 10 | |
| 11 | $code = (string)$input["code"]; |
| 12 | |
| 13 | if (secondFactor::completeCodeChallenge($code)) { |
| 14 | api::write(["status" => "ok"]); |
| 15 | } else { |
| 16 | api::write(["status" => "wrongCode"]); |
| 17 | } |