From 2568db9bed01c53d13e5ebf4312ba3e54d5e40e5 Mon Sep 17 00:00:00 2001
From: tykayn
Date: Tue, 5 Jan 2021 17:18:53 +0100
Subject: [PATCH] honeypot feature on register form
---
js/src/views/User/Login.vue | 24 ++++-----
js/src/views/User/Register.vue | 92 ++++++++++++++++++++++++++++++++++
2 files changed, 104 insertions(+), 12 deletions(-)
diff --git a/js/src/views/User/Login.vue b/js/src/views/User/Login.vue
index 88c11e713..1e5e6ed1e 100644
--- a/js/src/views/User/Login.vue
+++ b/js/src/views/User/Login.vue
@@ -8,8 +8,8 @@
title="Info"
type="is-info"
:aria-close-label="$t('Close')"
- >{{ $t("You need to login.") }}
+ >{{ $t("You need to login.") }}
+
+ }}
+
+ }}
+
{{ $t("Forgot your password ?") }}
+ >{{ $t("Forgot your password ?") }}
+
{{ $t("Didn't receive the instructions?") }}
+ >{{ $t("Didn't receive the instructions?") }}
+
{{ $t("Create an account") }}
+ >{{ $t("Create an account") }}
+
diff --git a/js/src/views/User/Register.vue b/js/src/views/User/Register.vue
index 9b02d28c6..fc01e08a6 100644
--- a/js/src/views/User/Register.vue
+++ b/js/src/views/User/Register.vue
@@ -87,6 +87,21 @@
:message="errors.email"
label-for="email"
>
+
+
+
+
+
+
+
+
+
+
+
= {};
@@ -243,7 +293,41 @@ export default class Register extends Vue {
return "";
}
+ mounted() {
+ this.populate_honeypots();
+ }
+ /**
+ * generate random strings in honeypots
+ */
+ populate_honeypots(): void {
+ this.credentials.honey_potter = Math.random().toString(16).substr(2, 128);
+ this.credentials.honey_potter_backup = Object.create(
+ this.credentials.honey_potter
+ );
+ this.credentials.honey_potter_two = Math.random()
+ .toString(16)
+ .substr(2, 128);
+ this.credentials.honey_potter_backup = Object.create(
+ this.credentials.honey_potter_two
+ );
+ }
+
+ /**
+ * checks that honeypots fields did not change
+ */
+ validate_honeypots(): boolean {
+ return (
+ this.credentials.honey_potter_nothing === "" &&
+ this.credentials.honey_potter === this.credentials.honey_potter_backup &&
+ this.credentials.honey_potter_two ===
+ this.credentials.honey_potter_two_backup
+ );
+ }
+
async submit(): Promise {
+ if (this.sendingForm || !this.validate_honeypots()) {
+ return;
+ }
this.sendingForm = true;
this.credentials.locale = this.$i18n.locale;
try {
@@ -304,4 +388,12 @@ p.create-account {
margin: 1rem auto 2rem;
}
}
+
+.bees-home {
+ overflow: hidden;
+ width: 0;
+ height: 0;
+ display: block;
+ position: absolute;
+}