diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-31 10:02:36 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-31 10:02:36 +0000 |
commit | 60f60de8aefeebd1de0bf6c940558902226d7747 (patch) | |
tree | ed3a5b3f9f721d559d29f872073bc293a66a99d0 /src/account-server/dalstorage.cpp | |
parent | e681c0024c1db3f93c501a0a9600371440986674 (diff) | |
download | manaserv-60f60de8aefeebd1de0bf6c940558902226d7747.tar.gz manaserv-60f60de8aefeebd1de0bf6c940558902226d7747.tar.bz2 manaserv-60f60de8aefeebd1de0bf6c940558902226d7747.tar.xz manaserv-60f60de8aefeebd1de0bf6c940558902226d7747.zip |
Plugged several account leaks on error. Prevented banned players from logging in.
Diffstat (limited to 'src/account-server/dalstorage.cpp')
-rw-r--r-- | src/account-server/dalstorage.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp index 31606e8f..70b1cdfb 100644 --- a/src/account-server/dalstorage.cpp +++ b/src/account-server/dalstorage.cpp @@ -429,6 +429,26 @@ DALStorage::getEmailList() } #endif +bool DALStorage::doesUserNameExist(std::string const &name) +{ + try { + std::ostringstream sql; + sql << "select count(username) from " << ACCOUNTS_TBL_NAME + << " where username = \"" << name << "\";"; + dal::RecordSet const &accountInfo = mDb->execSql(sql.str()); + + std::istringstream ssStream(accountInfo(0, 0)); + unsigned int iReturn = 1; + ssStream >> iReturn; + return iReturn != 0; + } catch (std::exception const &e) { + // TODO: throw an exception. + LOG_ERROR("(DALStorage::doesUserNameExist) SQL query failure: " << e.what()); + } + + return true; +} + /** * Tells if the email address already exists * @return true if the email address exists. |