|
|
|
@ -103,7 +103,7 @@ impl Game {
|
|
|
|
|
false,
|
|
|
|
|
Some(State::Login(Login::Username)),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
check::PlayerCheck::Err(err) => {
|
|
|
|
@ -117,8 +117,7 @@ impl Game {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Login::CreatePassword2((username, pass)) => {
|
|
|
|
|
match pass.check(message) {
|
|
|
|
|
Login::CreatePassword2((username, pass)) => match pass.check(message) {
|
|
|
|
|
Ok(true) => {
|
|
|
|
|
if let Ok(id) = self.db.new_player_id() {
|
|
|
|
|
let player = Player {
|
|
|
|
@ -151,7 +150,7 @@ impl Game {
|
|
|
|
|
} else {
|
|
|
|
|
send_queue.push(token, "Error", true, None);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
Ok(false) => {
|
|
|
|
|
send_queue.push(token, "\n\nPasswords don't match", false, None);
|
|
|
|
|
send_queue.push(
|
|
|
|
@ -165,7 +164,6 @@ impl Game {
|
|
|
|
|
log_error!("Error creating password :: {}", e);
|
|
|
|
|
send_queue.push(token, "\nError\n\n", false, None);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Login::Password(username) => {
|
|
|
|
@ -179,8 +177,7 @@ impl Game {
|
|
|
|
|
} else {
|
|
|
|
|
match self.db.find_player_by_name(username) {
|
|
|
|
|
Ok(Some(player)) => match self.db.get_password(player.id) {
|
|
|
|
|
Ok(Some(password)) => {
|
|
|
|
|
match password.check(message) {
|
|
|
|
|
Ok(Some(password)) => match password.check(message) {
|
|
|
|
|
Ok(true) => {
|
|
|
|
|
if self.db.save_connected_player(token, &player).is_ok() {
|
|
|
|
|
send_queue.push(
|
|
|
|
@ -219,8 +216,7 @@ impl Game {
|
|
|
|
|
log_error!("Error creating password :: {}", e);
|
|
|
|
|
send_queue.push(token, "\nError\n\n", false, None);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Ok(None) => {
|
|
|
|
|
log_error!("Player has no password: {}", player.id);
|
|
|
|
|
send_queue.push(token, "Error\n", false, None);
|
|
|
|
|