- // if we did, this means we may now request a row... there should be only one row for each user, so,
- // we don't need to loop to fetch multiple rows.
- SQLRequest* rowrequest = new SQLRequest(SQL_ROW,dbid,"");
- Request rowquery((char*)rowrequest, this, SQLModule);
- SQLResult* rowresult = (SQLResult*)rowquery.Send();
+ bool CheckCredentials(User* user)
+ {
+ SQLrequest req = SQLreq(this, SQLprovider, databaseid, "SELECT ? FROM ? WHERE ? = '?' AND ? = ?'?')", userfield, usertable, userfield, user->nick, passfield, encryption, user->password);
+
+ 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->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
+ return false;
+ }
+ }
+
+ virtual char* OnRequest(Request* request)
+ {
+ if(strcmp(SQLRESID, request->GetId()) == 0)
+ {
+ SQLresult* res = static_cast<SQLresult*>(request);