From f853002a9050d238233c392b1649dfaf7407838b Mon Sep 17 00:00:00 2001 From: rasul Date: Wed, 8 Apr 2020 09:26:31 -0500 Subject: [PATCH] check for valid password at creation --- src/game/state/login.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/game/state/login.rs b/src/game/state/login.rs index fc434e0..a79d8a2 100644 --- a/src/game/state/login.rs +++ b/src/game/state/login.rs @@ -73,9 +73,21 @@ impl Game { send_queue.push(token, "\n\nUsername: ", false, None); client.state = State::Login(Login::Username); } else { - send_queue.push(token, "\nNew password again: ", false, None); - client.state = - State::Login(Login::CreatePassword2((username.to_owned(), message))); + match self.check_player_password(message) { + PlayerCheck::Ok(pass) => { + send_queue.push(token, "\nNew password again: ", false, None); + client.state = + State::Login(Login::CreatePassword2((username.to_owned(), pass))); + }, + PlayerCheck::Err(err) => { + send_queue.push(token, "\nInvalid password:\n", false, None); + for line in err { + send_queue.push(token, format!("{}\n", line), false, None); + } + send_queue.push(token, "\nNew password: ", false, None); + } + } + } }