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, username: username,
password: password, password: password,
consent: elements[6].checked, consent: elements[6].checked,
captcha_key: elements[7]?.value
}), }),
headers: { headers: {
"content-type": "application/json" "content-type": "application/json"
@ -28,6 +29,17 @@ async function registertry(e) {
method: "POST" method: "POST"
}).then(e => { }).then(e => {
e.json().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) { if (!e.token) {
console.log(e); console.log(e);
document.getElementById("wrong").textContent = e.errors[Object.keys(e.errors)[0]]._errors[0].message; 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> <b id="TOSbox">I agree to the <a href="" id="TOSa">Terms of Service</a>:</b>
<input type="checkbox" id="TOS" name="TOS"/><br> <input type="checkbox" id="TOS" name="TOS"/><br>
<p class="wrongred" id="wrong"></p><br> <p class="wrongred" id="wrong"></p><br>
<div id="h-captcha">
</div>
<button type="submit">Create account</button> <button type="submit">Create account</button>
</form> </form>
<a href="/login.html">Already have an account?</a> <a href="/login.html">Already have an account?</a>

View file

@ -23,6 +23,7 @@ async function registertry(e){
username:username, username:username,
password:password, password:password,
consent:elements[6].checked, consent:elements[6].checked,
captcha_key:elements[7]?.value
}), }),
headers:{ headers:{
"content-type": "application/json" "content-type": "application/json"
@ -30,6 +31,18 @@ async function registertry(e){
method:"POST" method:"POST"
}).then(e=>{ }).then(e=>{
e.json().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){ if(!e.token){
console.log(e); console.log(e);
document.getElementById("wrong").textContent=e.errors[Object.keys(e.errors)[0]]._errors[0].message; document.getElementById("wrong").textContent=e.errors[Object.keys(e.errors)[0]]._errors[0].message;