Skip to content

Commit 03707d4

Browse files
committed
hcaptcha goes crazy
1 parent 9870a30 commit 03707d4

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

auth.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ body {
264264
box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
265265
}
266266

267+
.h-captcha {
268+
display: flex;
269+
justify-content: center;
270+
margin: 12px auto;
271+
}
272+
267273
.btn-welcome-secondary {
268274
background: transparent;
269275
border: 1px solid #dadce0;

auth.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<link href="https://fonts.googleapis.com/css?family=Poppins" rel="stylesheet">
1515
<link rel="stylesheet" href="./auth.css">
1616
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js"></script>
17+
<script src="https://hcaptcha.com/1/api.js" async defer></script>
1718
</head>
1819

1920
<body>
@@ -95,6 +96,9 @@ <h1>Create your Rotur account</h1>
9596
<div class="form-group">
9697
<input type="password" name="confirm-password" placeholder="Confirm password" required minlength="8">
9798
</div>
99+
<div class="form-group" style="margin-top: 12px;">
100+
<div class="h-captcha" data-sitekey="09def114-5bba-4ba6-8302-640aec7c1df2"></div>
101+
</div>
98102
<button type="submit" class="btn-primary">Create Account</button>
99103
</form>
100104
<div style="margin-top: 16px; text-align: center;">
@@ -690,6 +694,17 @@ <h2 style="margin:0 0 4px; font-size:22px; font-weight:500;">Link This Account</
690694
const password = document.querySelector("#signup-form input[name='password']").value;
691695
const confirmPassword = document.querySelector("#signup-form input[name='confirm-password']").value;
692696

697+
const hcaptchaToken = hcaptcha.getResponse();
698+
if (!hcaptchaToken) {
699+
submitButton.innerHTML = 'Please complete the hCaptcha';
700+
submitButton.style.background = '#ea4335';
701+
setTimeout(() => {
702+
submitButton.innerHTML = originalText;
703+
submitButton.style.background = '';
704+
}, 2000);
705+
return;
706+
}
707+
693708
// Validation
694709
if (password !== confirmPassword) {
695710
submitButton.innerHTML = 'Passwords do not match';
@@ -726,7 +741,8 @@ <h2 style="margin:0 0 4px; font-size:22px; font-weight:500;">Link This Account</
726741
username: username,
727742
email: email,
728743
password: hash,
729-
system: systemName || 'rotur'
744+
system: systemName || 'rotur',
745+
captcha: hcaptchaToken
730746
})
731747
});
732748

0 commit comments

Comments
 (0)