Project import generated by Copybara.

GitOrigin-RevId: 63746295f1a5ab5a619056791995793d65529e62
diff --git a/src/ajax/verifysecuritycode.php b/src/ajax/verifysecuritycode.php
new file mode 100644
index 0000000..9e5899e
--- /dev/null
+++ b/src/ajax/verifysecuritycode.php
@@ -0,0 +1,17 @@
+<?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"]);
+}