added hcaptcha

master
Dominika Liberda 2020-11-18 17:49:55 +01:00
parent 35e0e14eb7
commit cf01903187
4 changed files with 17 additions and 7 deletions

View File

@ -2,3 +2,5 @@ cfg[index]='index.html'
worker_add updateKeys 5400
cfg[who]='LauDom Enterprises' # who sent this message
cfg[hcaptcha]=false
cfg[hcaptcha_secret]=''

View File

@ -419,6 +419,7 @@ window.addEventListener("load", () => {
login: (form.querySelector('input[name="login"]')! as HTMLInputElement).value,
password: (form.querySelector('input[name="password"]')! as HTMLInputElement).value,
mail: (form.querySelector('input[name="email"]')! as HTMLInputElement).value,
hcaptcha: (form.querySelector('textarea[name="h-captcha-response"]')! as HTMLInputElement).value,
});
if (res.status == 200) {
hideElements([".register-box", ".login-box"]);

View File

@ -3,7 +3,10 @@ source "${cfg[namespace]}/code/common.sh"
if [[ "${post_data[login]}" != '' && "${post_data[password]}" != '' && "${post_data[mail]}" != '' ]]; then
mail="$(echo "${post_data[mail]}" | sed -s 's/%40/@/')"
if ! check_mail "$mail"; then
if [[ "${cfg[hcaptcha]}" == true && $(curl -d "response=${post_data[hcaptcha]}&secret=${cfg[hcaptcha_secret]}" -X POST https://hcaptcha.com/siteverify | jq '.success') != "true" ]]; then
status=1
reason="hCaptcha: invalid token"
elif ! check_mail "$mail"; then
status=1
reason="This mail address is already in use!"
else
@ -25,4 +28,6 @@ Have a wonderful day!
elif [[ $status == 1 && $reason != '' ]]; then
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "$reason"
fi
else
jq -n '{status: $ARGS.positional[0], msg: $ARGS.positional[1]}' --args -1 "Make sure to fill out the form properly."
fi

View File

@ -33,13 +33,13 @@
<div class="field">
<label for="login" class="label">Username</label>
<div class="control">
<input type="text" name="login" class="input" placeholder="dominika">
<input type="text" name="login" class="input" placeholder="dominika" required>
</div>
</div>
<div class="field">
<label for="password" class="label">Password</label>
<div class="control">
<input type="password" name="password" class="input" placeholder="***** ***">
<input type="password" name="password" class="input" placeholder="***** ***" required>
</div>
</div>
<div class="control">
@ -53,29 +53,30 @@
<div class="field">
<label for="login" class="label">Username</label>
<div class="control">
<input type="text" name="login" class="input" placeholder="laura">
<input type="text" name="login" class="input" placeholder="laura" required>
</div>
</div>
<div class="field">
<label for="password" class="label">Password</label>
<div class="control">
<input type="password" name="password" class="input" placeholder="***** ***">
<input type="password" name="password" class="input" placeholder="***** ***" required>
</div>
</div>
<div class="field">
<label for="email" class="label">E-mail address</label>
<div class="control">
<input type="email" name="email" class="input" placeholder="@2137.pl">
<input type="email" name="email" class="input" placeholder="@2137.pl" required>
</div>
<p class="help">For password recovery. Verified on account registration</p>
</div>
<div class="field">
<label for="phone" class="label">Phone number</label>
<div class="control">
<input type="tel" name="phone" class="input" placeholder="222922597">
<input type="tel" name="phone" class="input" placeholder="222922597" required>
</div>
<p class="help">The one your packages are assigned to</p>
</div>
<div class="h-captcha" data-sitekey="06ade6bc-1e3f-42be-85d8-f578c2c9de90"></div>
<div class="control">
<input type="submit" class="button" value="Register">
</div>
@ -187,5 +188,6 @@
</div>
</div>
<script src="assets/index.js"></script>
<script src="https://hcaptcha.com/1/api.js" async defer></script>
</body>
</html>