]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Add honeypot fields and minimum fill-out time for sign-up form
authorThibG <thib@sitedethib.com>
Thu, 10 Dec 2020 05:27:26 +0000 (06:27 +0100)
committerClaire <claire.github-309c@sitedethib.com>
Thu, 10 Dec 2020 08:44:16 +0000 (09:44 +0100)
Port 49eb4d4ddf61e25c5aaab89aa630ddd3c7f3c23d to glitch-soc

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
app/javascript/flavours/glitch/packs/public.js
app/javascript/flavours/glitch/styles/forms.scss

index c74e5c9af144fafc862750d407382f1d14d21cf0..dccdbc8d0fa891047f1da1b05a8000ec3bfcb826 100644 (file)
@@ -151,6 +151,17 @@ function main() {
       target.style.display = 'block';
     }
   });
+
+  // Empty the honeypot fields in JS in case something like an extension
+  // automatically filled them.
+  delegate(document, '#registration_new_user,#new_user', 'submit', () => {
+    ['user_website', 'user_confirm_password', 'registration_user_website', 'registration_user_confirm_password'].forEach(id => {
+      const field = document.getElementById(id);
+      if (field) {
+        field.value = '';
+      }
+    });
+  });
 }
 
 loadPolyfills()
index d53567bc36302d764727fc6465c28f79d9cc248b..20dc3eb82031900182657bcf863093e42e8cafe2 100644 (file)
@@ -345,6 +345,7 @@ code {
   input[type=number],
   input[type=email],
   input[type=password],
+  input[type=url],
   textarea {
     box-sizing: border-box;
     font-size: 16px;
@@ -985,3 +986,10 @@ code {
     flex-direction: row;
   }
 }
+
+.input.user_confirm_password,
+.input.user_website {
+  &:not(.field_with_errors) {
+    display: none;
+  }
+}