fix: load Turnstile without onload callback
All checks were successful
Tests / Backend - Tests skipped: 8, passed: 74
Backend Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 78.38% (551/703)
* Lines of Code: 703
#### Quality Gates Summary
No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 83
Frontend Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 80.85% (553/684)
* Lines of Code: 684
#### Quality Gates Summary
No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
All checks were successful
Tests / Backend - Tests skipped: 8, passed: 74
Backend Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 78.38% (551/703)
* Lines of Code: 703
#### Quality Gates Summary
No active quality gates.
Tests / Frontend - Lint, Tests et Build passed: 83
Frontend Coverage #### Project Overview
No changes detected, that affect the code coverage.
* Line Coverage: 80.85% (553/684)
* Lines of Code: 684
#### Quality Gates Summary
No active quality gates.
THE-TIP-TOP-MULTIBRANCH/pipeline/head This commit looks good
This commit is contained in:
@@ -27,7 +27,7 @@ export default function Captcha({ onToken }) {
|
||||
try {
|
||||
window.turnstile.remove(widgetIdRef.current)
|
||||
} catch {
|
||||
// Rien à faire
|
||||
// Widget déjà supprimé
|
||||
}
|
||||
|
||||
widgetIdRef.current = null
|
||||
@@ -41,6 +41,7 @@ export default function Captcha({ onToken }) {
|
||||
sitekey: TURNSTILE_SITE_KEY,
|
||||
language: 'fr',
|
||||
size: 'flexible',
|
||||
appearance: 'always',
|
||||
|
||||
callback: (token) => {
|
||||
onToken(token)
|
||||
@@ -66,23 +67,28 @@ export default function Captcha({ onToken }) {
|
||||
return
|
||||
}
|
||||
|
||||
const previousCallback = window.onloadTurnstileCallback
|
||||
if (existingScript) {
|
||||
existingScript.addEventListener('load', renderWidget, {
|
||||
once: true,
|
||||
})
|
||||
|
||||
window.onloadTurnstileCallback = () => {
|
||||
previousCallback?.()
|
||||
renderWidget()
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}
|
||||
|
||||
if (!existingScript) {
|
||||
const script = document.createElement('script')
|
||||
|
||||
script.id = TURNSTILE_SCRIPT_ID
|
||||
script.src = `${TURNSTILE_SCRIPT_URL}&onload=onloadTurnstileCallback`
|
||||
script.src = TURNSTILE_SCRIPT_URL
|
||||
script.async = true
|
||||
script.defer = true
|
||||
|
||||
script.addEventListener('load', renderWidget, {
|
||||
once: true,
|
||||
})
|
||||
|
||||
document.head.appendChild(script)
|
||||
}
|
||||
|
||||
return () => {
|
||||
cancelled = true
|
||||
@@ -94,7 +100,7 @@ export default function Captcha({ onToken }) {
|
||||
try {
|
||||
window.turnstile.remove(widgetIdRef.current)
|
||||
} catch {
|
||||
// Rien à faire
|
||||
// Widget déjà supprimé
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user