From 018cbe1feef64a8985b76175b50923344e89cfc1 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 26 Apr 2019 07:34:04 -0700 Subject: [PATCH] Fixing rust warning. - Fixes #111 --- server/Cargo.toml | 1 + server/src/websocket_server/server.rs | 5 +++++ ui/src/components/login.tsx | 14 ++++++++------ ui/src/interfaces.ts | 1 + 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/server/Cargo.toml b/server/Cargo.toml index 93bd6acb..1daaca66 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -2,6 +2,7 @@ name = "server" version = "0.0.1" authors = ["Dessalines "] +autobins = false [[bin]] name = "lemmy" diff --git a/server/src/websocket_server/server.rs b/server/src/websocket_server/server.rs index dbd1be8d..d6a9226b 100644 --- a/server/src/websocket_server/server.rs +++ b/server/src/websocket_server/server.rs @@ -92,6 +92,7 @@ pub struct Register { password: String, password_verify: String, admin: bool, + spam_timer: i64, } #[derive(Serialize, Deserialize)] @@ -789,6 +790,10 @@ impl Perform for Register { return Err(self.error("Passwords do not match."))? } + if self.spam_timer < 1142 { + return Err(self.error("Too fast"))? + } + if has_slurs(&self.username) { return Err(self.error("No slurs"))? } diff --git a/ui/src/components/login.tsx b/ui/src/components/login.tsx index e6dec2d2..0713b776 100644 --- a/ui/src/components/login.tsx +++ b/ui/src/components/login.tsx @@ -10,7 +10,6 @@ interface State { registerForm: RegisterForm; loginLoading: boolean; registerLoading: boolean; - spamTimer: number; } @@ -27,10 +26,10 @@ export class Login extends Component { password: undefined, password_verify: undefined, admin: false, + spam_timer: undefined, }, loginLoading: false, registerLoading: false, - spamTimer: new Date().getTime() } constructor(props: any, context: any) { @@ -126,7 +125,7 @@ export class Login extends Component { - +