Refactor: Replace reCAPTCHA with Turnstile on dashboard

This commit is contained in:
2025-12-15 12:28:22 -08:00
parent 03dbb83a6f
commit da17921d61

View File

@@ -9,7 +9,6 @@
<script src="https://cdn.tailwindcss.com"></script> <script src="https://cdn.tailwindcss.com"></script>
<script src="//unpkg.com/alpinejs" defer></script> <script src="//unpkg.com/alpinejs" defer></script>
<script src="https://unpkg.com/lucide@latest"></script> <script src="https://unpkg.com/lucide@latest"></script>
<script src="https://www.google.com/recaptcha/api.js?render=explicit" async defer></script>
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit" async defer></script> <script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit" async defer></script>
<link rel="preconnect" href="https://fonts.bunny.net"> <link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=plus-jakarta-sans:400,500,600,700" rel="stylesheet" /> <link href="https://fonts.bunny.net/css?family=plus-jakarta-sans:400,500,600,700" rel="stylesheet" />
@@ -152,7 +151,7 @@
> >
</div> </div>
</div> </div>
<div class="recaptcha-container my-4 flex justify-center"></div> <div class="turnstile-container my-4 flex justify-center"></div>
<p <p
x-text="error" x-text="error"
x-show="error" x-show="error"
@@ -487,13 +486,13 @@
copied:!1, copied:!1,
widgetId:null, widgetId:null,
renderCaptcha(){ renderCaptcha(){
if(!window.grecaptcha?.render) if(!window.turnstile?.render)
return setTimeout(()=>this.renderCaptcha(),100); return setTimeout(()=>this.renderCaptcha(),100);
this.$nextTick(()=>{ this.$nextTick(()=>{
const e=this.$el.querySelector(".recaptcha-container"); const e=this.$el.querySelector(".turnstile-container");
e&&(e.innerHTML="", e&&(e.innerHTML="",
this.widgetId=grecaptcha.render(e,{ this.widgetId=turnstile.render(e,{
sitekey:"6LdzaxMsAAAAAEXKHhzqVEFHvnOPIh19MFU1qrO3" sitekey:"0x4AAAAAAB54R0OUQDyuiUS5"
})) }))
}) })
}, },
@@ -501,7 +500,7 @@
this.loading=!0, this.loading=!0,
this.error="", this.error="",
this.result={}; this.result={};
const o=grecaptcha.getResponse(this.widgetId); const o=turnstile.getResponse(this.widgetId);
if(!o) if(!o)
return this.error="Please complete the CAPTCHA.", return this.error="Please complete the CAPTCHA.",
this.loading=!1, this.loading=!1,
@@ -519,7 +518,7 @@
slug:this.slug||null, slug:this.slug||null,
username:e, username:e,
pass_hash:s, pass_hash:s,
"g-recaptcha-response":o "cf-turnstile-response":o
}) })
}); });
if(!t.ok) if(!t.ok)
@@ -538,7 +537,7 @@
this.error=e.message this.error=e.message
}finally{ }finally{
this.loading=!1, this.loading=!1,
grecaptcha.reset(this.widgetId) turnstile.reset(this.widgetId)
} }
} }
} }