mirror of
https://github.com/pyrohost/pyrodactyl.git
synced 2026-04-06 04:01:58 +02:00
chore: debugging
This commit is contained in:
@@ -25,26 +25,57 @@ class VerifyCaptcha
|
||||
// Skip verification if captcha is not enabled
|
||||
$defaultDriver = $this->captcha->getDefaultDriver();
|
||||
|
||||
Log::info('VerifyCaptcha middleware triggered', [
|
||||
'default_driver' => $defaultDriver,
|
||||
'request_url' => $request->url(),
|
||||
'request_method' => $request->method(),
|
||||
]);
|
||||
|
||||
if ($defaultDriver === 'none') {
|
||||
Log::info('Captcha verification skipped - driver is none');
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// Get the captcha response from the request
|
||||
$driver = $this->captcha->driver();
|
||||
$captchaResponse = $request->input($driver->getResponseFieldName());
|
||||
$fieldName = $driver->getResponseFieldName();
|
||||
$captchaResponse = $request->input($fieldName);
|
||||
|
||||
Log::info('Captcha verification details', [
|
||||
'driver_name' => $driver->getName(),
|
||||
'field_name' => $fieldName,
|
||||
'response_present' => !empty($captchaResponse),
|
||||
'response_length' => $captchaResponse ? strlen($captchaResponse) : 0,
|
||||
'all_request_keys' => array_keys($request->all()),
|
||||
]);
|
||||
|
||||
if (empty($captchaResponse)) {
|
||||
Log::warning('Captcha verification failed - no response provided', [
|
||||
'field_name' => $fieldName,
|
||||
'request_data' => $request->all(),
|
||||
]);
|
||||
throw new DisplayException('Please complete the captcha verification.');
|
||||
}
|
||||
|
||||
// Verify the captcha response
|
||||
$remoteIp = $request->ip();
|
||||
Log::info('Starting captcha verification', [
|
||||
'remote_ip' => $remoteIp,
|
||||
'response_preview' => substr($captchaResponse, 0, 50) . '...',
|
||||
]);
|
||||
|
||||
$verificationResult = $this->captcha->verify($captchaResponse, $remoteIp);
|
||||
|
||||
Log::info('Captcha verification completed', [
|
||||
'result' => $verificationResult,
|
||||
]);
|
||||
|
||||
if (!$verificationResult) {
|
||||
Log::warning('Captcha verification failed - verification returned false');
|
||||
throw new DisplayException('Captcha verification failed. Please try again.');
|
||||
}
|
||||
|
||||
Log::info('Captcha verification successful - proceeding with request');
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,19 @@ class TurnstileProvider implements CaptchaProviderInterface
|
||||
*/
|
||||
public function verify(string $response, ?string $remoteIp = null): bool
|
||||
{
|
||||
Log::info('Turnstile verification attempt', [
|
||||
'response_length' => strlen($response),
|
||||
'response_preview' => substr($response, 0, 50) . '...',
|
||||
'remote_ip' => $remoteIp,
|
||||
'secret_key_set' => !empty($this->secretKey),
|
||||
'site_key' => $this->siteKey,
|
||||
]);
|
||||
|
||||
if (empty($this->secretKey) || empty($response)) {
|
||||
Log::warning('Turnstile verification failed: Missing secret key or response', [
|
||||
'secret_key_empty' => empty($this->secretKey),
|
||||
'response_empty' => empty($response),
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,28 +64,50 @@ class TurnstileProvider implements CaptchaProviderInterface
|
||||
$data['remoteip'] = $remoteIp;
|
||||
}
|
||||
|
||||
Log::info('Sending Turnstile verification request', [
|
||||
'url' => $this->verifyUrl,
|
||||
'data_keys' => array_keys($data),
|
||||
'remote_ip' => $remoteIp,
|
||||
]);
|
||||
|
||||
$httpResponse = Http::timeout(10)
|
||||
->asForm()
|
||||
->post($this->verifyUrl, $data);
|
||||
|
||||
Log::info('Turnstile verification response', [
|
||||
'status' => $httpResponse->status(),
|
||||
'successful' => $httpResponse->successful(),
|
||||
'body' => $httpResponse->body(),
|
||||
]);
|
||||
|
||||
if (!$httpResponse->successful()) {
|
||||
Log::warning('Turnstile verification failed: HTTP ' . $httpResponse->status());
|
||||
Log::warning('Turnstile verification failed: HTTP ' . $httpResponse->status(), [
|
||||
'response_body' => $httpResponse->body(),
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = $httpResponse->json();
|
||||
|
||||
if (!isset($result['success'])) {
|
||||
Log::warning('Turnstile verification failed: Invalid response format');
|
||||
Log::warning('Turnstile verification failed: Invalid response format', [
|
||||
'result' => $result,
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$result['success'] && isset($result['error-codes'])) {
|
||||
Log::warning('Turnstile verification failed', [
|
||||
'error_codes' => $result['error-codes'],
|
||||
'full_result' => $result,
|
||||
]);
|
||||
}
|
||||
|
||||
Log::info('Turnstile verification result', [
|
||||
'success' => $result['success'],
|
||||
'full_result' => $result,
|
||||
]);
|
||||
|
||||
return (bool) $result['success'];
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Turnstile verification exception', [
|
||||
|
||||
Reference in New Issue
Block a user