blob: 7dd504ee087d9c2f822d07ec45ef83f4dc64070c [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"]) || !secondFactor::hasSecurityKeys($_SESSION["firstfactorid"]) || $_SERVER['REQUEST_METHOD'] !== "POST") {
5 api::error();
6}
7
8try {
9 $result = secondFactor::createValidationChallenge();
10} catch (Throwable $e) {
11 api::error($conf['debug'] ? $e->getMessage() : null);
12}
13
14if (isset($result->publicKey)) $result->publicKey->rpId = ($conf["secondFactor"]["origin"] ?? null);
15
16api::write($result);