aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/extra/m_sqlauth.cpp
diff options
context:
space:
mode:
authorGravatar w00t2007-05-13 12:50:24 +0000
committerGravatar w00t2007-05-13 12:50:24 +0000
commitcb8e65e27064cb632050f1975aec27ed81cbefae (patch)
treedf4d2ad54737eb86849589cae379c5e43ca1da61 /src/modules/extra/m_sqlauth.cpp
parentAdd README to docs directory giving links to various stuff (bugtracker, wiki,... (diff)
Make this FindFeature once, and store the result. It was different dating back from before we had module interfaces. Thanks LeaChim :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7009 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra/m_sqlauth.cpp')
-rw-r--r--src/modules/extra/m_sqlauth.cpp46
1 files changed, 19 insertions, 27 deletions
diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp
index 8b1b4a5ea..be8998e17 100644
--- a/src/modules/extra/m_sqlauth.cpp
+++ b/src/modules/extra/m_sqlauth.cpp
@@ -50,6 +50,10 @@ public:
if (!SQLutils)
throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqlauth.so.");
+ SQLprovider = Srv->FindFeature("SQL");
+ if (!SQLprovider)
+ throw ModuleException("Can't find an SQL provider module. Please load one before attempting to load m_sqlauth.");
+
OnRehash(NULL,"");
}
@@ -103,37 +107,25 @@ public:
bool CheckCredentials(userrec* user)
{
- Module* target;
-
- target = Srv->FindFeature("SQL");
-
- if(target)
- {
- SQLrequest req = SQLreq(this, target, databaseid, "SELECT ? FROM ? WHERE ? = '?' AND ? = ?'?')", userfield, usertable, userfield, user->nick, passfield, encryption, user->password);
+ 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 userrec
- * 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)
- Srv->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
- return false;
- }
+ 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 userrec
+ * 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
{
- ServerInstance->Log(SPARSE, "WARNING: Couldn't find SQL provider module. NOBODY will be allowed to connect until it comes back unless they match an exception");
+ if (verbose)
+ Srv->WriteOpers("Forbidden connection from %s!%s@%s (SQL query failed: %s)", user->nick, user->ident, user->host, req.error.Str());
return false;
}
}