std::string killreason;
std::string allowpattern;
std::string databaseid;
-
+
bool verbose;
-
+
public:
ModuleSQLAuth(InspIRCd* Me)
- : Module::Module(Me)
+ : Module(Me)
{
ServerInstance->Modules->UseInterface("SQLutils");
ServerInstance->Modules->UseInterface("SQL");
virtual int OnUserRegister(User* user)
{
- if ((!allowpattern.empty()) && (ServerInstance->MatchText(user->nick,allowpattern)))
+ if ((!allowpattern.empty()) && (InspIRCd::Match(user->nick,allowpattern)))
{
user->Extend("sqlauthed");
return 0;
}
-
+
if (!CheckCredentials(user))
{
ServerInstance->Users->QuitUser(user, killreason);
{
std::string thisquery = freeformquery;
std::string safepass = user->password;
-
+
/* Search and replace the escaped nick and escaped pass into the query */
SearchAndReplace(safepass, "\"", "");
/* 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,
* us to discard the query.
*/
AssociateUser(this, SQLutils, req.id, user).Send();
-
+
return true;
}
else
return false;
}
}
-
+
virtual const char* OnRequest(Request* request)
{
if(strcmp(SQLRESID, request->GetId()) == 0)
User* user = GetAssocUser(this, SQLutils, res->id).S().user;
UnAssociate(this, SQLutils, res->id).S();
-
+
if(user)
{
- if(res->error.Id() == NO_ERROR)
+ if(res->error.Id() == SQL_NO_ERROR)
{
if(res->Rows())
{
ServerInstance->Users->QuitUser(user, killreason);
}
return SQLSUCCESS;
- }
+ }
return NULL;
}
-
+
virtual void OnUserDisconnect(User* user)
{
user->Shrink("sqlauthed");
- user->Shrink("sqlauth_failed");
+ user->Shrink("sqlauth_failed");
}
-
+
virtual bool OnCheckReady(User* user)
{
return user->GetExt("sqlauthed");
virtual Version GetVersion()
{
- return Version(1,2,1,0,VF_VENDOR,API_VERSION);
+ return Version("$Id$", VF_VENDOR, API_VERSION);
}
-
+
};
MODULE_INIT(ModuleSQLAuth)