]> Untitled Git - lemmy-ui.git/commitdiff
Add honeypot for user and form creation. Fixes #433 (#435)
authorDessalines <dessalines@users.noreply.github.com>
Fri, 1 Oct 2021 14:19:47 +0000 (10:19 -0400)
committerGitHub <noreply@github.com>
Fri, 1 Oct 2021 14:19:47 +0000 (10:19 -0400)
package.json
src/assets/css/main.css
src/shared/components/home/signup.tsx
src/shared/components/post/post-form.tsx
yarn.lock

index 65e11446a142853e4cbb4fb522dea4bb5dc7cbbe..77ee390eed8fd1887e886c924f71b66fcee3b404 100644 (file)
@@ -72,7 +72,7 @@
     "husky": "^7.0.2",
     "import-sort-style-module": "^6.0.0",
     "iso-639-1": "^2.1.9",
-    "lemmy-js-client": "0.13.0",
+    "lemmy-js-client": "0.13.1-rc.1",
     "lint-staged": "^11.0.1",
     "mini-css-extract-plugin": "^2.3.0",
     "node-fetch": "^2.6.1",
index 2e6c7cb39955bf849b5ff0a174518665cdebd945..641b7bee7bf63244e98ccb0969088f7609c56f44 100644 (file)
@@ -364,3 +364,7 @@ br.big {
 .tribute-container .menu-highlighted {
   font-weight: bold;
 }
+
+.honeypot {
+  display:none !important;
+}
index 722f644fe4ce1e82105fcb00ad525cd0d3b13db0..1452ba07616ee975990c390781038fc7aeb98df3 100644 (file)
@@ -1,3 +1,5 @@
+import { Options, passwordStrength } from "check-password-strength";
+import { I18nKeys } from "i18next";
 import { Component, linkEvent } from "inferno";
 import { T } from "inferno-i18next-dess";
 import {
@@ -10,7 +12,6 @@ import {
 } from "lemmy-js-client";
 import { Subscription } from "rxjs";
 import { i18n } from "../../i18next";
-import { Options, passwordStrength } from "check-password-strength";
 import { UserService, WebSocketService } from "../../services";
 import {
   authField,
@@ -26,7 +27,6 @@ import {
 } from "../../utils";
 import { HtmlTags } from "../common/html-tags";
 import { Icon, Spinner } from "../common/icon";
-import {I18nKeys} from "i18next";
 
 const passwordStrengthOptions: Options<string> = [
   {
@@ -76,6 +76,7 @@ export class Signup extends Component<any, State> {
       show_nsfw: false,
       captcha_uuid: undefined,
       captcha_answer: undefined,
+      honeypot: undefined,
     },
     registerLoading: false,
     captcha: undefined,
@@ -272,6 +273,16 @@ export class Signup extends Component<any, State> {
             </T>
           </div>
         )}
+        <input
+          tabIndex={-1}
+          autoComplete="false"
+          name="a_password"
+          type="text"
+          class="form-control honeypot"
+          id="register-honey"
+          value={this.state.registerForm.honeypot}
+          onInput={linkEvent(this, this.handleHoneyPotChange)}
+        />
         <div class="form-group row">
           <div class="col-sm-10">
             <button type="submit" class="btn btn-secondary">
@@ -371,6 +382,11 @@ export class Signup extends Component<any, State> {
     i.setState(i.state);
   }
 
+  handleHoneyPotChange(i: Signup, event: any) {
+    i.state.registerForm.honeypot = event.target.value;
+    i.setState(i.state);
+  }
+
   handleRegenCaptcha(i: Signup) {
     i.audio = null;
     i.state.captchaPlaying = false;
index 7793dd72b911f37f3826c7ab83cca6566f2022e5..40e8e7bc79a07e3d417c8b613c1dfacb9fc88ccb 100644 (file)
@@ -326,6 +326,16 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
               </div>
             </div>
           )}
+          <input
+            tabIndex={-1}
+            autoComplete="false"
+            name="a_password"
+            type="text"
+            class="form-control honeypot"
+            id="register-honey"
+            value={this.state.postForm.honeypot}
+            onInput={linkEvent(this, this.handleHoneyPotChange)}
+          />
           <div class="form-group row">
             <div class="col-sm-10">
               <button
@@ -466,6 +476,11 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
     i.setState(i.state);
   }
 
+  handleHoneyPotChange(i: PostForm, event: any) {
+    i.state.postForm.honeypot = event.target.value;
+    i.setState(i.state);
+  }
+
   handleCancel(i: PostForm) {
     i.props.onCancel();
   }
index 8795f38ade4dbc62df4af6451596c2026f9a9961..cc5e52e9f237dce0f2c11d20453eecd4c95a0f77 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -4915,10 +4915,10 @@ lcid@^1.0.0:
   dependencies:
     invert-kv "^1.0.0"
 
-lemmy-js-client@0.13.0:
-  version "0.13.0"
-  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.13.0.tgz#fc15f603a8492e0c2542a3b55fb4df06a182b4fc"
-  integrity sha512-7RBgbd3hOTq8fb+oef3B8U1O1UmIutTI0n+fx0EMHjFIselYwBwHhpSD6/ORtPPMXDY5MS6jiwO5QV7blSQRtA==
+lemmy-js-client@0.13.1-rc.1:
+  version "0.13.1-rc.1"
+  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.13.1-rc.1.tgz#e1af4749a5493954a17f87b7b20dcccb8c585f22"
+  integrity sha512-fncCq6Zu8s6GpeCrkmJS8/rqXcyrJ8p8EyWfXiiuZlWkgzOIi+qZjTRnO63wI6DomYwVOjwk7sry4RbOJSdK5Q==
 
 levn@^0.4.1:
   version "0.4.1"