diff options
Diffstat (limited to 'modules/webcpanel/pages/index.cpp')
-rw-r--r-- | modules/webcpanel/pages/index.cpp | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp index 1ef1e8942..42b61246b 100644 --- a/modules/webcpanel/pages/index.cpp +++ b/modules/webcpanel/pages/index.cpp @@ -1,13 +1,26 @@ /* - * (C) 2003-2017 Anope Team - * Contact us at team@anope.org + * Anope IRC Services * - * Please read COPYING and README for further details. + * Copyright (C) 2012-2017 Anope Team <team@anope.org> + * + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ #include "../webcpanel.h" +#include "modules/nickserv.h" -class WebpanelRequest : public IdentifyRequest +class WebpanelRequest : public NickServ::IdentifyRequestListener { HTTPReply reply; HTTPMessage message; @@ -17,22 +30,22 @@ class WebpanelRequest : public IdentifyRequest TemplateFileServer::Replacements replacements; public: - WebpanelRequest(Module *o, HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re, const Anope::string &user, const Anope::string &pass) : IdentifyRequest(o, user, pass), reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { } + WebpanelRequest(HTTPReply &r, HTTPMessage &m, HTTPProvider *s, const Anope::string &p_n, HTTPClient *c, TemplateFileServer::Replacements &re) : reply(r), message(m), server(s), page_name(p_n), client(c), replacements(re) { } - void OnSuccess() anope_override + void OnSuccess(NickServ::IdentifyRequest *req) override { if (!client || !server) return; - NickAlias *na = NickAlias::Find(this->GetAccount()); + ::NickServ::Nick *na = ::NickServ::FindNick(req->GetAccount()); if (!na) { - this->OnFail(); + this->OnFail(req); return; } - if (na->nc->HasExt("NS_SUSPENDED")) + if (na->GetAccount()->HasFieldS("NS_SUSPENDED")) { - this->OnFail(); + this->OnFail(req); return; } @@ -51,12 +64,12 @@ class WebpanelRequest : public IdentifyRequest { HTTPReply::cookie c; - c.push_back(std::make_pair("account", na->nick)); + c.push_back(std::make_pair("account", na->GetNick())); c.push_back(std::make_pair("Path", "/")); reply.cookies.push_back(c); } - { + { HTTPReply::cookie c; c.push_back(std::make_pair("id", id)); c.push_back(std::make_pair("Path", "/")); @@ -69,7 +82,7 @@ class WebpanelRequest : public IdentifyRequest client->SendReply(&reply); } - void OnFail() anope_override + void OnFail(NickServ::IdentifyRequest *req) override { if (!client || !server) return; @@ -88,12 +101,12 @@ bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page replacements["TITLE"] = page_title; - if (!user.empty() && !pass.empty()) + if (!user.empty() && !pass.empty() && ::NickServ::service) { - // Rate limit check. + // XXX Rate limit check. - WebpanelRequest *req = new WebpanelRequest(me, reply, message, server, page_name, client, replacements, user, pass); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); + ::NickServ::IdentifyRequest *req = ::NickServ::service->CreateIdentifyRequest(new WebpanelRequest(reply, message, server, page_name, client, replacements), me, user, pass); + EventManager::Get()->Dispatch(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); return false; } |