Hcaptcha support on login/register

This commit is contained in:
Madeline 2022-07-20 14:02:11 +10:00
parent c1b096cfd1
commit 3b9ffce42c
3 changed files with 17 additions and 1 deletions

View File

@ -104,3 +104,9 @@ label {
color: rgb(200, 20, 20); color: rgb(200, 20, 20);
display: none; display: none;
} }
.h-captcha {
display: flex;
justify-content: center;
margin-top: 10px;
}

View File

@ -41,6 +41,9 @@
href="https://discord.com/api/oauth2/authorize?client_id=991688571415175198&redirect_uri=https%3A%2F%2Fslowcord.maddy.k.vu%2Foauth%2Fdiscord&response_type=code&scope=identify%20email"> href="https://discord.com/api/oauth2/authorize?client_id=991688571415175198&redirect_uri=https%3A%2F%2Fslowcord.maddy.k.vu%2Foauth%2Fdiscord&response_type=code&scope=identify%20email">
Login with Discord Login with Discord
</a> </a>
<div class="h-captcha" data-sitekey="fa3163ea-79a7-4b7b-b752-b58c545906c8"></div>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
</form> </form>
</div> </div>
</div> </div>
@ -67,11 +70,13 @@
const data = new FormData(e.target); const data = new FormData(e.target);
const email = data.get("email"); const email = data.get("email");
const password = data.get("password"); const password = data.get("password");
const hcaptcha = data.get("h-captcha-response");
await handleSubmit("/api/v9/auth/login", { await handleSubmit("/api/v9/auth/login", {
login: email, login: email,
password: password, password: password,
}) captcha_key: hcaptcha,
});
}) })
</script> </script>
</body> </body>

View File

@ -47,6 +47,9 @@
href="https://discord.com/api/oauth2/authorize?client_id=991688571415175198&redirect_uri=https%3A%2F%2Fslowcord.maddy.k.vu%2Foauth%2Fdiscord&response_type=code&scope=identify%20email"> href="https://discord.com/api/oauth2/authorize?client_id=991688571415175198&redirect_uri=https%3A%2F%2Fslowcord.maddy.k.vu%2Foauth%2Fdiscord&response_type=code&scope=identify%20email">
Login with Discord Login with Discord
</a> </a>
<div class="h-captcha" data-sitekey="fa3163ea-79a7-4b7b-b752-b58c545906c8"></div>
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
</form> </form>
</div> </div>
</div> </div>
@ -58,6 +61,7 @@
const username = data.get("username"); const username = data.get("username");
const password = data.get("password"); const password = data.get("password");
const dob = data.get("dob"); const dob = data.get("dob");
const hcaptcha = data.get("h-captcha-response")
await handleSubmit("/api/v9/auth/register", { await handleSubmit("/api/v9/auth/register", {
consent: true, consent: true,
@ -65,6 +69,7 @@
username: username, username: username,
password: password, password: password,
date_of_birth: dob, date_of_birth: dob,
captcha_key: hcaptcha,
}); });
}) })
</script> </script>