summaryrefslogtreecommitdiff
path: root/src/modules/m_sqlauth.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-12-22 02:47:54 +0000
committerPeter Powell <petpow@saberuk.com>2017-12-22 16:49:01 +0000
commitb6f57c0f06f4905b04de6ec2069522d2263626c4 (patch)
treed682ab49c248abeaf68f90d49f3322feb738f492 /src/modules/m_sqlauth.cpp
parentc8f515121fbdf3e4de693712ef2311cece45477d (diff)
Improve and modernize the SQL system API.
- Move everything into the SQL namespace and drop the SQL prefix. - Move SQLProvider::PopulateUserInfo to SQL::PopulateUserInfo. - Rename SQLEntry to SQL::Field and clean up. - Rename SQLEntries to SQL::Row. - Rename SQLerror to SQL::Error and clean up. - Rename SQLerrorNum to SQL::ErrorCode and drop the SQL_ prefix. - Rename ParamL to SQL::ParamList. - Rename ParamM to SQL::ParamMap; - Make implementing SQLQuery::OnError mandatory. - Redo most of the documentation in the sql header.
Diffstat (limited to 'src/modules/m_sqlauth.cpp')
-rw-r--r--src/modules/m_sqlauth.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/modules/m_sqlauth.cpp b/src/modules/m_sqlauth.cpp
index 1a5b68dd9..4c6a221b7 100644
--- a/src/modules/m_sqlauth.cpp
+++ b/src/modules/m_sqlauth.cpp
@@ -28,18 +28,21 @@ enum AuthState {
AUTH_STATE_FAIL = 2
};
-class AuthQuery : public SQLQuery
+class AuthQuery : public SQL::Query
{
public:
const std::string uid;
LocalIntExt& pendingExt;
bool verbose;
AuthQuery(Module* me, const std::string& u, LocalIntExt& e, bool v)
- : SQLQuery(me), uid(u), pendingExt(e), verbose(v)
+ : SQL::Query(me)
+ , uid(u)
+ , pendingExt(e)
+ , verbose(v)
{
}
- void OnResult(SQLResult& res) CXX11_OVERRIDE
+ void OnResult(SQL::Result& res) CXX11_OVERRIDE
{
User* user = ServerInstance->FindNick(uid);
if (!user)
@@ -56,21 +59,21 @@ class AuthQuery : public SQLQuery
}
}
- void OnError(SQLerror& error) CXX11_OVERRIDE
+ void OnError(SQL::Error& error) CXX11_OVERRIDE
{
User* user = ServerInstance->FindNick(uid);
if (!user)
return;
pendingExt.set(user, AUTH_STATE_FAIL);
if (verbose)
- ServerInstance->SNO->WriteGlobalSno('a', "Forbidden connection from %s (SQL query failed: %s)", user->GetFullRealHost().c_str(), error.Str());
+ ServerInstance->SNO->WriteGlobalSno('a', "Forbidden connection from %s (SQL query failed: %s)", user->GetFullRealHost().c_str(), error.ToString());
}
};
class ModuleSQLAuth : public Module
{
LocalIntExt pendingExt;
- dynamic_reference<SQLProvider> SQL;
+ dynamic_reference<SQL::Provider> SQL;
std::string freeformquery;
std::string killreason;
@@ -120,8 +123,8 @@ class ModuleSQLAuth : public Module
pendingExt.set(user, AUTH_STATE_BUSY);
- ParamM userinfo;
- SQL->PopulateUserInfo(user, userinfo);
+ SQL::ParamMap userinfo;
+ SQL::PopulateUserInfo(user, userinfo);
userinfo["pass"] = user->password;
HashProvider* md5 = ServerInstance->Modules->FindDataService<HashProvider>("hash/md5");
@@ -135,7 +138,7 @@ class ModuleSQLAuth : public Module
const std::string certfp = SSLClientCert::GetFingerprint(&user->eh);
userinfo["certfp"] = certfp;
- SQL->submit(new AuthQuery(this, user->uuid, pendingExt, verbose), freeformquery, userinfo);
+ SQL->Submit(new AuthQuery(this, user->uuid, pendingExt, verbose), freeformquery, userinfo);
return MOD_RES_PASSTHRU;
}