turnstile

Drupal paywall plugin
Log | Files | Refs | README | LICENSE

commit 1a50f0b18f3148a65059c54f0dc7cdd1af4000a3
parent 54a3b44c4792c1765ccf93316c3bcdbe92f745a1
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 19 Oct 2025 16:37:04 +0200

fix minor issues

Diffstat:
Msrc/Form/TurnstileSettingsForm.php | 12------------
Msrc/TalerMerchantApiService.php | 2+-
2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/src/Form/TurnstileSettingsForm.php b/src/Form/TurnstileSettingsForm.php @@ -147,20 +147,17 @@ class TurnstileSettingsForm extends ConfigFormBase { { $form_state->setErrorByName('payment_backend_url', $this->t('Payment backend URL must end with a "/".')); - $form_state->setErrorByName('access_token'); return; } if (! $this->apiService->checkConfig($payment_backend_url)) { $form_state->setErrorByName('payment_backend_url', $this->t('Invalid payment backend URL')); - $form_state->setErrorByName('access_token'); return; } if ( (!empty($access_token)) && (!str_starts_with($access_token, 'secret-token:')) ) { - $form_state->setErrorByName('payment_backend_url'); $form_state->setErrorByName('access_token', $this->t('Access token must begin with a "secret-token:".')); return; @@ -171,25 +168,20 @@ class TurnstileSettingsForm extends ConfigFormBase { case 502: $form_state->setErrorByName('payment_backend_url', $this->t('Bad gateway (502) trying to access the merchant backend')); - $form_state->setErrorByName('access_token'); return; case 500: $form_state->setErrorByName('payment_backend_url', $this->t('Internal server error (500) of the merchant backend reported')); - $form_state->setErrorByName('access_token'); return; case 404: $form_state->setErrorByName('payment_backend_url', $this->t('The specified instance is unknown to the merchant backend')); - $form_state->setErrorByName('access_token'); return; case 403: - $form_state->setErrorByName('payment_backend_url'); $form_state->setErrorByName('access_token', $this->t('Access token not accepted by the merchant backend')); return; case 401: - $form_state->setErrorByName('payment_backend_url'); $form_state->setErrorByName('access_token', $this->t('Access token not accepted by the merchant backend')); return; @@ -202,12 +194,10 @@ class TurnstileSettingsForm extends ConfigFormBase { case 0: $form_state->setErrorByName('payment_backend_url', $this->t('HTTP request failed')); - $form_state->setErrorByName('access_token'); return; default: $form_state->setErrorByName('payment_backend_url', $this->t('Unexpected response (' . $response->getStatusCode() . ') from merchant backend')); - $form_state->setErrorByName('access_token'); return; } // end switch on HTTP status @@ -218,8 +208,6 @@ class TurnstileSettingsForm extends ConfigFormBase { if ( (! $grant_access_on_error) && (empty($payment_backend_url) || empty($access_token)) ) { - $form_state->setErrorByName('payment_backend_url'); - $form_state->setErrorByName('access_token'); $this->messenger()->addWarning( $this->t('Warning: Merchant backend is not configured correctly. To keep the site working, you probably should set the "Disable Turnstile when payment backend is unavailable" option!')); return; diff --git a/src/TalerMerchantApiService.php b/src/TalerMerchantApiService.php @@ -158,7 +158,7 @@ class TalerMerchantApiService { 'timeout' => 5, // seconds ]); $response = $http_client->get( - $payment_backend_url . 'private/orders?limit=1' + $backend_url . 'private/orders?limit=1' ); return $response->getStatusCode(); } catch (\Exception $e) {