Skip to content

Commit

Permalink
fix hcaptcha not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Nov 17, 2024
1 parent b188b3f commit 1aa2299
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions apps/frontend/src/components/ui/HCaptcha.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
<script setup>
const token = defineModel();
const id = ref(null);
useHead({
script: [
{
src: "https://js.hcaptcha.com/1/api.js",
async: true,
defer: true,
},
],
});
function updateToken(newToken) {
function hCaptchaUpdateToken(newToken) {
token.value = newToken;
}
function hCaptchaReady() {
window.hCaptchaUpdateToken = hCaptchaUpdateToken;
id.value = window.hcaptcha.render("h-captcha");
}
onMounted(() => {
window.updateCatpchaToken = updateToken;
window.hCaptchaReady = hCaptchaReady;
useHead({
script: [
{
src: "https://js.hcaptcha.com/1/api.js?render=explicit&onload=hCaptchaReady",
async: true,
defer: true,
},
],
});
});
defineExpose({
reset: () => {
token.value = null;
window.hcaptcha.reset();
window.hcaptcha.reset(id.value);
},
});
</script>
Expand All @@ -33,7 +39,7 @@ defineExpose({
class="h-captcha"
data-sitekey="4a7a2c80-68f2-4190-9d52-131c76e0c14e"
:data-theme="$theme.active === 'light' ? 'light' : 'dark'"
data-callback="updateCatpchaToken"
data-callback="hCaptchaUpdateToken"
></div>
</template>

Expand Down

0 comments on commit 1aa2299

Please sign in to comment.