Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 25ab224

Browse files
committed
integrate recaptcha
1 parent 5d8db96 commit 25ab224

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

‎public/register/index.html‎

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,46 +35,29 @@
3535
<h1>Blobs</h1>
3636
<input type="text" placeholder="Username" name="username" id="user" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
3737
<input type="password" placeholder="Password" name="password" id="pass" /><br/>
38-
<div id="captcha">
39-
<canvas width="250" height="100" id="captcha-canvas">
40-
Please use a browser that supports the canvas tag
41-
</canvas><br/>
42-
<input type="text" maxlength="16" placeholder="Answer" name="captcha-input" id="captcha-input" style="
43-
text-align: center;
44-
">
45-
</div>
38+
<input type="hidden" name="token" id="captcha-token" /><br />
4639
<input type="submit" value="Register" id="register-btn" />
4740
<span class="reg-label">Already have an account? <a href="../login">Login</a></span>
4841
</form>
4942
</div>
50-
<center><input type="submit" value="Play as guest" id="guest-btn" style="
43+
<div style="text-align: center;">
44+
<input type="submit" value="Play as guest" id="guest-btn" style="
5145
background-color: #27ae60;
52-
" onclick="document.location.href='/game?guest=true'"></center>
46+
" onclick="document.location.href='/game?guest=true'">
47+
</div>
5348
<a href="https://github.com/blobs-io/blobs.live" id="peek"></a>
5449
<span class="peek-label">Peek into the source</span>
5550
</body>
51+
<script src="https://www.google.com/recaptcha/api.js?render=6LdCUPMUAAAAAHu30n0EZ7mk8DLc_vATJZyK8u2m"></script>
5652
<script src="/js/particles.js"></script>
5753
<script>
58-
initParticles();
59-
(function() {
60-
const server = document.location.href.match(/https?:\/\/[^\/]+/)[0];
61-
const context = document.getElementById("captcha-canvas").getContext("2d");
62-
context.fillStyle = "white";
63-
context.font = "20px Arial";
64-
context.fillText("Requesting captcha...", 6, 20);
54+
// reCAPTCHA
55+
grecaptcha.ready(() => {
56+
grecaptcha.execute("6LdCUPMUAAAAAHu30n0EZ7mk8DLc_vATJZyK8u2m", { action: "homepage" }).then(token => {
57+
document.getElementById("captcha-token").value = token;
58+
});
59+
});
6560

66-
fetch("/api/captcha/request").then(async res => {
67-
if (res.status !== 200) {
68-
return alert("An error occurred while trying to request a captcha");
69-
}
70-
const response = await res.json();
71-
console.log(server + response.url);
72-
const image = new Image();
73-
image.src = server + response.url;
74-
image.onload = () => {
75-
context.drawImage(image, 0, 0, 250, 100);
76-
};
77-
}).catch(console.error);
78-
})();
61+
initParticles();
7962
</script>
8063
</html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /