void LoginState::processNewPassword(const std::string &input, std::shared_ptr<Connection> connection) { Account account = connection->GetAccount(); int connection_id = connection->GetID(); //TODO: validate password account.SetUsername(connection->GetUsername()); account.SetPassword(input); game_data->AddAccount(account); game_data->SaveAccounts(GameData::ACCOUNT_FILE); Sender::Send("Account created\r\n", connection); connection->SetState(GameStates::CHARACTERCREATION, game_data); m_state_map.erase(connection_id); }
void LoginState::processPassword(const std::string &input, std::shared_ptr<Connection> connection) { Account account = connection->GetAccount(); int connection_id = connection->GetID(); if (account.MatchPassword(input)) { Sender::Send("Logged In!\r\n", connection); connection->SetState(GameStates::CHARACTERCREATION, game_data); m_state_map.erase(connection_id); } else { Sender::Send("Bad password\r\n", connection); connection->SetUsername(""); account.SetUsername(""); // TODO: change to allow for 3 attempts reset(connection); } }