Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame^] | 1 | <?php |
| 2 | require_once("core.php"); |
| 3 | security::checkType(security::WORKER, security::METHOD_NOTFOUND); |
| 4 | security::checkWorkerUIEnabled(); |
| 5 | secondFactor::checkAvailability(); |
| 6 | |
| 7 | if (!secondFactor::isEnabled()) { |
| 8 | security::notFound(); |
| 9 | } |
| 10 | |
| 11 | if (!security::checkParams("POST", [ |
| 12 | ["id", security::PARAM_ISSET] |
| 13 | ])) { |
| 14 | security::go("security.php?msg=empty"); |
| 15 | } |
| 16 | |
| 17 | $id = (int)$_POST["id"]; |
| 18 | |
| 19 | $url = ((security::isAllowed(security::ADMIN) && $id != people::userData("id")) ? "users.php" : "security.php"); |
| 20 | |
| 21 | if (!security::isAllowed(security::ADMIN)) { |
| 22 | if ($id != people::userData("id")) security::notFound(); |
| 23 | |
| 24 | if (!security::checkParams("POST", [ |
| 25 | ["password", security::PARAM_ISSET] |
| 26 | ])) { |
| 27 | security::go($url."?msg=empty"); |
| 28 | } |
| 29 | |
| 30 | $password = (string)$_POST["password"]; |
| 31 | |
| 32 | if (!security::isUserPassword(false, $password)) security::go($url."?msg=wrongpassword"); |
| 33 | } |
| 34 | |
| 35 | if (secondFactor::disable($id)) { |
| 36 | security::go($url."?msg=disabledsecondfactor"); |
| 37 | } else { |
| 38 | security::go($url."?msg=unexpected"); |
| 39 | } |