Skip to content

Commit

Permalink
Move javascript library url to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
maccabeelevine committed Nov 27, 2024
1 parent ecd4a2f commit 08d612f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion config/vufind/RateLimiter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,8 @@ Policies:
# siteKey: 0x1234567890
# secretKey: 0x1234567890

# Verify API URL. Default is https://challenges.cloudflare.com/turnstile/v0/siteverify
# Verify API URL. Default is below.
# verifyUrl: https://challenges.cloudflare.com/turnstile/v0/siteverify

# API Javascript file. Default is below.
# jsLibraryUrl: https://challenges.cloudflare.com/turnstile/v0/api.js
2 changes: 2 additions & 0 deletions module/VuFind/src/VuFind/Controller/TurnstileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public function challengeAction()
$yamlReader = $this->getService(\VuFind\Config\YamlReader::class);
$config = $yamlReader->get('RateLimiter.yaml');
$context['siteKey'] = $config['Turnstile']['siteKey'];
$context['jsLibraryUrl'] = $config['Turnstile']['jsLibraryUrl'] ??
'https://challenges.cloudflare.com/turnstile/v0/api.js';

$this->layout()->searchbox = false;
return $this->createViewModel($context);
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/templates/turnstile/challenge.phtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$this->headScript()->appendFile('https://challenges.cloudflare.com/turnstile/v0/api.js', 'text/javascript', ['defer' => '', 'async' => '']);
$this->headScript()->appendFile($jsLibraryUrl, 'text/javascript', ['defer' => '', 'async' => '']);
$js = <<<JS
function turnstileChallengeEnded(token) {
document.getElementById('turnstile_token').setAttribute('value', token);
Expand Down

0 comments on commit 08d612f

Please sign in to comment.