]> Untitled Git - lemmy.git/commitdiff
Fix rate limit on signup fail.
authorDessalines <tyhou13@gmx.com>
Wed, 11 Sep 2019 01:26:33 +0000 (18:26 -0700)
committerDessalines <tyhou13@gmx.com>
Wed, 11 Sep 2019 01:26:33 +0000 (18:26 -0700)
- Fixes #273

server/src/websocket/server.rs

index ea9f8a8aaaee2f434ba89c54f1046f65c7813d8d..08714c30b6684d9137b858b1ce4f01aad983f0a1 100644 (file)
@@ -305,10 +305,12 @@ fn parse_json_message(chat: &mut ChatServer, msg: StandardMessage) -> Result<Str
       Ok(serde_json::to_string(&res)?)
     }
     UserOperation::Register => {
-      chat.check_rate_limit_register(msg.id)?;
       let register: Register = serde_json::from_str(data)?;
-      let res = Oper::new(user_operation, register).perform()?;
-      Ok(serde_json::to_string(&res)?)
+      let res = Oper::new(user_operation, register).perform();
+      if res.is_ok() {
+        chat.check_rate_limit_register(msg.id)?;
+      }
+      Ok(serde_json::to_string(&res?)?)
     }
     UserOperation::GetUserDetails => {
       let get_user_details: GetUserDetails = serde_json::from_str(data)?;