Created
May 6, 2011 23:43
-
-
Save apathyboy/960012 to your computer and use it in GitHub Desktop.
example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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