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