Skip to content

Commit

Permalink
fix: update method name
Browse files Browse the repository at this point in the history
  • Loading branch information
phacUFPE committed Sep 12, 2024
1 parent 77ea934 commit c08791d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/account/account_repository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AccountRepository {
virtual bool loadBySession(const std::string &email, AccountInfo &acc) = 0;
virtual bool save(const AccountInfo &accInfo) = 0;

virtual bool getCharacterByNameAndAccountId(const uint32_t &id, const std::string &name) = 0;
virtual bool getCharacterByAccountIdAndName(const uint32_t &id, const std::string &name) = 0;

virtual bool getPassword(const uint32_t &id, std::string &password) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/account/account_repository_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool AccountRepositoryDB::save(const AccountInfo &accInfo) {
return successful;
};

bool AccountRepositoryDB::getCharacterByNameAndAccountId(const uint32_t &id, const std::string &name) {
bool AccountRepositoryDB::getCharacterByAccountIdAndName(const uint32_t &id, const std::string &name) {
auto result = g_database().storeQuery(fmt::format("SELECT `id` FROM `players` WHERE `account_id` = {} AND `name` = {}", id, g_database().escapeString(name)));
if (!result) {
g_logger().error("Failed to get character: [{}] from account: [{}]!", name, id);
Expand Down
2 changes: 1 addition & 1 deletion src/account/account_repository_db.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AccountRepositoryDB final : public AccountRepository {
bool loadBySession(const std::string &esseionKey, AccountInfo &acc) override;
bool save(const AccountInfo &accInfo) override;

bool getCharacterByNameAndAccountId(const uint32_t &id, const std::string &name) override;
bool getCharacterByAccountIdAndName(const uint32_t &id, const std::string &name) override;

bool getPassword(const uint32_t &id, std::string &password) override;

Expand Down
2 changes: 1 addition & 1 deletion src/io/iologindata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool IOLoginData::gameWorldAuthentication(const std::string &accountDescriptor,
}
}

if (!g_accountRepository().getCharacterByNameAndAccountId(account.getID(), characterName)) {
if (!g_accountRepository().getCharacterByAccountIdAndName(account.getID(), characterName)) {
g_logger().warn("IP [{}] trying to connect into another account character", convertIPToString(ip));
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/account/in_memory_account_repository.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace tests {
return true;
}

bool getCharacterByNameAndAccountId(const uint32_t &id, const std::string &name) final {
bool getCharacterByAccountIdAndName(const uint32_t &id, const std::string &name) final {
for (auto it = accounts.begin(); it != accounts.end(); ++it) {
if (it->second.id == id) {
if (it->second.players.find(name) != it->second.players.end()) {
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/account/account_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ suite<"account"> accountTest = [] {
expect(acc.authenticate());
};

test("Account::getCharacterByNameAndAccountId using an account with the given character.") = [&injectionFixture] {
test("Account::getCharacterByAccountIdAndName using an account with the given character.") = [&injectionFixture] {
auto [accountRepository] = injectionFixture.get<AccountRepository>();

Account acc { 1 };
Expand All @@ -602,12 +602,12 @@ suite<"account"> accountTest = [] {
AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD, { { "Canary", 1 }, { "Canary2", 2 } }, false, getTimeNow() + 24 * 60 * 60 * 1000 }
);

const auto hasCharacter = accountRepository.getCharacterByNameAndAccountId(1, "Canary");
const auto hasCharacter = accountRepository.getCharacterByAccountIdAndName(1, "Canary");

expect(hasCharacter);
};

test("Account::getCharacterByNameAndAccountId using an account without the given character.") = [&injectionFixture] {
test("Account::getCharacterByAccountIdAndName using an account without the given character.") = [&injectionFixture] {
auto [accountRepository] = injectionFixture.get<AccountRepository>();

Account acc { 1 };
Expand All @@ -616,7 +616,7 @@ suite<"account"> accountTest = [] {
AccountInfo { 1, 1, 1, AccountType::ACCOUNT_TYPE_GOD, { { "Canary", 1 }, { "Canary2", 2 } }, false, getTimeNow() + 24 * 60 * 60 * 1000 }
);

const auto hasCharacter = accountRepository.getCharacterByNameAndAccountId(1, "Invalid");
const auto hasCharacter = accountRepository.getCharacterByAccountIdAndName(1, "Invalid");

expect(!hasCharacter);
};
Expand Down

0 comments on commit c08791d

Please sign in to comment.