blob: 1252d7ce10cd7cc2b2dae2117d79c961e5715eb2 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<?php
2require_once("core.php");
3security::checkType(security::WORKER);
4security::checkWorkerUIEnabled();
5secondFactor::checkAvailability();
6
7if (!security::checkParams("POST", [
8 ["id", security::PARAM_NEMPTY]
9])) {
10 security::go("securitykeys.php?msg=unexpected");
11}
12
13$id = (int)$_POST["id"];
14
15$s = secondFactor::getSecurityKeyById($id);
16if ($s === false || people::userData("id") != $s["person"]) security::go("securitykeys.php?msg=unexpected");
17
18if (secondFactor::removeSecurityKey($id)) {
19 security::go("securitykeys.php?msg=securitykeydeleted");
20} else {
21 security::go("securitykeys.php?msg=unexpected");
22}