diff --git a/config.sh b/config.sh index 64c4b74..a74e0ca 100644 --- a/config.sh +++ b/config.sh @@ -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]='' diff --git a/front/src/index.ts b/front/src/index.ts index 1360750..583a3d9 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -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"]); diff --git a/webroot/api/register.shs b/webroot/api/register.shs index 3934b93..2fc1a11 100644 --- a/webroot/api/register.shs +++ b/webroot/api/register.shs @@ -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 diff --git a/webroot/index.html b/webroot/index.html index fd6af06..580d4a5 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -33,13 +33,13 @@
- +
- +
@@ -53,29 +53,30 @@
- +
- +
- +

For password recovery. Verified on account registration

- +

The one your packages are assigned to

+
@@ -187,5 +188,6 @@
+