Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::WORKER); |
| 4 | security::checkWorkerUIEnabled(); |
| 5 | secondFactor::checkAvailability(); |
| 6 | |
| 7 | if (!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); |
| 16 | if ($s === false || people::userData("id") != $s["person"]) security::go("securitykeys.php?msg=unexpected"); |
| 17 | |
| 18 | if (secondFactor::removeSecurityKey($id)) { |
| 19 | security::go("securitykeys.php?msg=securitykeydeleted"); |
| 20 | } else { |
| 21 | security::go("securitykeys.php?msg=unexpected"); |
| 22 | } |