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