diff options
| author | Adam <Adam@anope.org> | 2012-10-07 22:39:58 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-10-07 22:39:58 -0400 |
| commit | b8b63ff115f0daddf479b0da507a2f731255a06d (patch) | |
| tree | d6b82bf0dfc39fdfe6a6a23ba318bb0c2906d6c1 /modules/extra/m_xmlrpc_main.cpp | |
| parent | 0a111c19764ed14ab5f724c78d9dd8c08a3c124f (diff) | |
Remove the asynchronous identifing hack and replace it with something better. Fixes m_*_authentication only being able to properly work when people identify normally using nickserv/identify
Diffstat (limited to 'modules/extra/m_xmlrpc_main.cpp')
| -rw-r--r-- | modules/extra/m_xmlrpc_main.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/modules/extra/m_xmlrpc_main.cpp b/modules/extra/m_xmlrpc_main.cpp index dc12d565e..cd7b68967 100644 --- a/modules/extra/m_xmlrpc_main.cpp +++ b/modules/extra/m_xmlrpc_main.cpp @@ -1,6 +1,37 @@ #include "module.h" #include "xmlrpc.h" +class XMLRPCIdentifyRequest : public IdentifyRequest +{ + XMLRPCRequest request; + dynamic_reference<XMLRPCServiceInterface> xinterface; + dynamic_reference<XMLRPCClientSocket> source; + + public: + XMLRPCIdentifyRequest(XMLRPCRequest& req, XMLRPCServiceInterface* iface, XMLRPCClientSocket* s, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(acc, pass), request(req), xinterface(iface), source(s) { } + + void OnSuccess() anope_override + { + if (!xinterface || !source) + return; + + request.reply("result", "Success"); + request.reply("account", GetAccount()); + + xinterface->Reply(source, &request); + } + + void OnFail() anope_override + { + if (!xinterface || !source) + return; + + request.reply("error", "Invalid password"); + + xinterface->Reply(source, &request); + } +}; + class MyXMLRPCEvent : public XMLRPCEvent { public: @@ -77,22 +108,9 @@ class MyXMLRPCEvent : public XMLRPCEvent request->reply("error", "Invalid parameters"); else { - const NickAlias *na = findnick(username); - - if (!na) - request->reply("error", "Invalid account"); - else - { - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnCheckAuthentication, OnCheckAuthentication(NULL, NULL, std::vector<Anope::string>(), na->nc->display, password)); - if (MOD_RESULT == EVENT_ALLOW) - { - request->reply("result", "Success"); - request->reply("account", na->nc->display); - } - else - request->reply("error", "Invalid password"); - } + XMLRPCIdentifyRequest *req = new XMLRPCIdentifyRequest(*request, iface, source, username, password); + FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(NULL, req)); + req->Dispatch(); } } |
