]> Untitled Git - lemmy.git/commitdiff
Spam
authorDessalines <tyhou13@gmx.com>
Fri, 26 Apr 2019 16:21:20 +0000 (09:21 -0700)
committerDessalines <tyhou13@gmx.com>
Fri, 26 Apr 2019 16:21:20 +0000 (09:21 -0700)
server/src/websocket_server/server.rs
ui/src/components/login.tsx
ui/src/css/main.css
ui/src/interfaces.ts

index d6a9226b2502409f93acf1bffff0b604dbc8ba83..9c609a47000fea9dc0eed0675095de5727c2e501 100644 (file)
@@ -92,7 +92,7 @@ pub struct Register {
   password: String,
   password_verify: String,
   admin: bool,
-  spam_timer: i64,
+  spam_timeri: i64,
 }
 
 #[derive(Serialize, Deserialize)]
@@ -790,7 +790,7 @@ impl Perform for Register {
       return Err(self.error("Passwords do not match."))?
     }
 
-    if self.spam_timer < 1142 {
+    if self.spam_timeri < 1142 {
       return Err(self.error("Too fast"))?
     }
 
index b64c7a7cdbbb119af321fb13017d607330749f7a..5c0b8dd1d9364c5e30a278659105955e5b96aa32 100644 (file)
@@ -27,7 +27,7 @@ export class Login extends Component<any, State> {
       password: undefined,
       password_verify: undefined,
       admin: false,
-      spam_timer: undefined,
+      spam_timeri: undefined,
     },
     loginLoading: false,
     registerLoading: false,
@@ -103,6 +103,7 @@ export class Login extends Component<any, State> {
     return (
       <form onSubmit={linkEvent(this, this.handleRegisterSubmit)}>
         <h5>Sign Up</h5>
+        <input type="text" class="no-s-hows" value={this.state.spamNada} onInput={linkEvent(this, this.handleSpamNada)} />
         <div class="form-group row">
           <label class="col-sm-2 col-form-label">Username</label>
           <div class="col-sm-10">
@@ -127,9 +128,7 @@ export class Login extends Component<any, State> {
             <input type="password" value={this.state.registerForm.password_verify} onInput={linkEvent(this, this.handleRegisterPasswordVerifyChange)} class="form-control" required />
           </div>
         </div>
-        <input type="hidden" value={this.state.registerForm.spam_timer} />
-        <input type="text" class="d-none" value={this.state.spamNada} onInput={linkEvent(this, this.handleSpamNada)} />
-        <input type="text" class="no-s-hows" value={this.state.spamNada} onInput={linkEvent(this, this.handleSpamNada)} />
+        <input type="hidden" value={this.state.registerForm.spam_timeri} />
         <div class="form-group row">
           <div class="col-sm-10">
             <button type="submit" class="btn btn-secondary">{this.state.registerLoading ? 
@@ -165,21 +164,19 @@ export class Login extends Component<any, State> {
     event.preventDefault();
 
     let endTimer = new Date().getTime();
-    let elapsed = endTimer - i.state.registerForm.spam_timer;
+    let elapsed = endTimer - i.state.registerForm.spam_timeri;
 
-    i.state.registerForm.spam_timer = elapsed;
+    i.state.registerForm.spam_timeri = elapsed;
     if (elapsed > 1423 && i.state.spamNada == undefined) {
       WebSocketService.Instance.register(i.state.registerForm);
     } else {
-      i.state.spamNada = "nt";
-      i.setState(i.state);
-      {/* window.location.href = "https://github.com/dessalines/lemmy"; */}
+      window.location.href = "https://github.com/dessalines/lemmy";
     }
   }
 
   handleRegisterUsernameChange(i: Login, event: any) {
     i.state.registerForm.username = event.target.value;
-    i.state.registerForm.spam_timer = new Date().getTime();
+    i.state.registerForm.spam_timeri = new Date().getTime();
     i.setState(i.state);
   }
 
index 1ddd33eb01323e6cfd596344d224af8c8ad54340..53d500b7e6f47230ce4c77d23e6fbe37cea644cf 100644 (file)
@@ -102,5 +102,7 @@ blockquote {
 }
 
 .no-s-hows {
-  display: none;
+  position: absolute !important;
+  top: -9999px !important;
+  left: -9999px !important;
 }
index 4fa30d188bced72325e6f234bee125d6514cb71b..51582f3a1ef80ca9c1319c30067fbecdfd1b7b00 100644 (file)
@@ -330,7 +330,7 @@ export interface RegisterForm {
   email?: string;
   password: string;
   password_verify: string;
-  spam_timer: number;
+  spam_timeri: number;
   admin: boolean;
 }