fixed captcha

This commit is contained in:
MathMan05 2024-07-28 15:03:29 -05:00
parent 6cea53dabd
commit 3621f1b09b
3 changed files with 28 additions and 0 deletions

View file

@ -21,6 +21,7 @@ async function registertry(e) {
username: username,
password: password,
consent: elements[6].checked,
captcha_key: elements[7]?.value
}),
headers: {
"content-type": "application/json"
@ -28,6 +29,17 @@ async function registertry(e) {
method: "POST"
}).then(e => {
e.json().then(e => {
if (e.captcha_sitekey) {
const capt = document.getElementById("h-captcha");
const capty = document.createElement("div");
capty.classList.add("h-captcha");
capty.setAttribute("data-sitekey", e.captcha_sitekey);
const script = document.createElement("script");
script.src = "https://js.hcaptcha.com/1/api.js";
capt.append(script);
capt.append(capty);
return;
}
if (!e.token) {
console.log(e);
document.getElementById("wrong").textContent = e.errors[Object.keys(e.errors)[0]]._errors[0].message;

View file

@ -31,6 +31,9 @@
<b id="TOSbox">I agree to the <a href="" id="TOSa">Terms of Service</a>:</b>
<input type="checkbox" id="TOS" name="TOS"/><br>
<p class="wrongred" id="wrong"></p><br>
<div id="h-captcha">
</div>
<button type="submit">Create account</button>
</form>
<a href="/login.html">Already have an account?</a>

View file

@ -23,6 +23,7 @@ async function registertry(e){
username:username,
password:password,
consent:elements[6].checked,
captcha_key:elements[7]?.value
}),
headers:{
"content-type": "application/json"
@ -30,6 +31,18 @@ async function registertry(e){
method:"POST"
}).then(e=>{
e.json().then(e=>{
if(e.captcha_sitekey){
const capt=document.getElementById("h-captcha");
const capty=document.createElement("div");
capty.classList.add("h-captcha");
capty.setAttribute("data-sitekey", e.captcha_sitekey);
const script=document.createElement("script");
script.src="https://js.hcaptcha.com/1/api.js";
capt.append(script);
capt.append(capty);
return;
}
if(!e.token){
console.log(e);
document.getElementById("wrong").textContent=e.errors[Object.keys(e.errors)[0]]._errors[0].message;