Skip to content

Instantly share code, notes, and snippets.

@apathyboy
Created May 6, 2011 23:43
Show Gist options
  • Select an option

  • Save apathyboy/960012 to your computer and use it in GitHub Desktop.

Select an option

Save apathyboy/960012 to your computer and use it in GitHub Desktop.
example
bool LoginManager::authenticateClient_(
LoginClient* client,
const std::string& username,
const std::string& password) const
{
shared_ptr<sql::Connection> conn = database_manager_->getConnection("default");
shared_ptr<sql::PreparedStatement> stmt(
conn->prepareStatement("CALL sp_ReturnUserAccount(?, ?)")
);
stmt->setString(1, username);
stmt->setString(2, password);
shared_ptr<sql::ResultSet> result(stmt->executeQuery());
if (!result->next()) {
return false;
}
client->setAccountId(result->getUInt("account_id"));
client->setCharsAllowed(result->getUInt("account_characters_allowed"));
client->setCsr(result->getUInt("account_csr"));
client->setUsername(username);
client->setPassword(password);
while (stmt->getMoreResults());
stmt.reset(
conn->prepareStatement("UPDATE account SET account_authenticated = 1 WHERE account_id = ?")
);
stmt->setUInt(1, client->getAccountId());
if (stmt->executeUpdate() == 1) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment