false, 'error' => 'method_not_allowed'], 405); } $raw = file_get_contents('php://input'); $data = json_decode($raw ?: '', true); if (!is_array($data)) { json_out(['ok' => false, 'error' => 'invalid_json'], 400); } $action = (string) ($data['action'] ?? 'register'); if ($action === 'verify') { $result = AuthRegistration::verifyEmailToken((string) ($data['token'] ?? '')); json_out($result, $result['ok'] ? 200 : 400); } if ($action === 'resend') { $result = AuthRegistration::resendVerification((string) ($data['email'] ?? '')); json_out($result, $result['ok'] ? 200 : 400); } if ($action === 'pending') { $pending = AuthRegistration::pendingVerification((string) ($data['email'] ?? '')); if ($pending === null) { json_out(['ok' => false, 'error' => 'not_pending'], 404); } json_out($pending, ($pending['ok'] ?? false) ? 200 : 410); } $email = (string) ($data['email'] ?? ''); $password = (string) ($data['password'] ?? ''); $username = (string) ($data['username'] ?? ''); $result = AuthRegistration::register($email, $password, $username); json_out($result, $result['ok'] ? 200 : 400);