/* Auth Function, builds SQL query for connecting user */ bool CheckCredentials(User* user) { std::string thisquery = freeformquery; std::string safepass = user->password; /* Search and replace the escaped nick and escaped pass into the query */ SearchAndReplace(safepass, "\"", ""); std::string* wnick; if (user->GetExt("wantsnick", wnick)) { SearchAndReplace(thisquery, "$nick", *wnick); } else { SearchAndReplace(thisquery, "$nick", user->nick); } SearchAndReplace(thisquery, "$pass", safepass); SearchAndReplace(thisquery, "$host", user->host); SearchAndReplace(thisquery, "$ip", user->GetIPString()); Module* HashMod = ServerInstance->Modules->Find("m_md5.so"); if (HashMod) { HashResetRequest(this, HashMod).Send(); SearchAndReplace(thisquery, "$md5pass", HashSumRequest(this, HashMod, user->password).Send()); } HashMod = ServerInstance->Modules->Find("m_sha256.so"); if (HashMod) { HashResetRequest(this, HashMod).Send(); SearchAndReplace(thisquery, "$sha256pass", HashSumRequest(this, HashMod, user->password).Send()); } /* Build the query */ SQLrequest req = SQLrequest(this, SQLprovider, databaseid, SQLquery(thisquery)); if(req.Send()) { /* When we get the query response from the service provider we will be given an ID to play with, * just an ID number which is unique to this query. We need a way of associating that ID with a User * so we insert it into a map mapping the IDs to users. * Thankfully m_sqlutils provides this, it will associate a ID with a user or channel, and if the user quits it removes the * association. This means that if the user quits during a query we will just get a failed lookup from m_sqlutils - telling * us to discard the query. */ AssociateUser(this, SQLutils, req.id, user).Send(); return true; } else { if (verbose) { ServerInstance->SNO->WriteToSnoMask('A', "Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), req.error.Str()); } return false; } }
void LoadUser(int account_id,int object_id) { AssociateUser(account_id,object_id); }