Commit 8f3839ef authored by Arnolds's avatar Arnolds
Browse files

Fixed request handling in secret-api.php: moved JSON decoding before POST...

Fixed request handling in secret-api.php: moved JSON decoding before POST check and updated condition to use decoded data.
parent e39e7760
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ $collection = $db->secrets;

$method = $_SERVER['REQUEST_METHOD'];

if ($method === 'POST' && isset($_POST['secret'])) {
$data = json_decode(file_get_contents('php://input'), true);
if ($method === 'POST' && isset($data['secret'])) {
    if ($data['secret']) {
        http_response_code(400);
        echo json_encode(['error' => '<p class="mb-0">Hmm... noslēpuma lauciņš ir tukšs. Bez tā šī ir tikai "Glabātuve", nevis "Noslēpumu glabātuve" 😅.</p>']);