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/commands/ns_identify.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/commands/ns_identify.cpp')
| -rw-r--r-- | modules/commands/ns_identify.cpp | 67 |
1 files changed, 44 insertions, 23 deletions
diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index cce0569dd..47df4255b 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -13,6 +13,47 @@ #include "module.h" +class NSIdentifyRequest : public IdentifyRequest +{ + CommandSource source; + Command *cmd; + + public: + NSIdentifyRequest(CommandSource &s, Command *c, const Anope::string &acc, const Anope::string &pass) : IdentifyRequest(acc, pass), source(s), cmd(c) { } + + void OnSuccess() anope_override + { + if (!source.GetUser()) + return; + + User *u = source.GetUser(); + NickAlias *na = findnick(GetAccount()); + + if (!na) + source.Reply(NICK_X_NOT_REGISTERED, GetAccount().c_str()); + else + { + if (u->IsIdentified()) + Log(LOG_COMMAND, source, cmd) << "to log out of account " << u->Account()->display; + + Log(LOG_COMMAND, source, cmd) << "and identified for account " << na->nc->display; + source.Reply(_("Password accepted - you are now recognized.")); + u->Identify(na); + na->Release(); + } + } + + void OnFail() anope_override + { + if (source.GetUser()) + { + Log(LOG_COMMAND, source, cmd) << "and failed to identify"; + source.Reply(PASSWORD_INCORRECT); + bad_password(source.GetUser()); + } + } +}; + class CommandNSIdentify : public Command { public: @@ -40,29 +81,9 @@ class CommandNSIdentify : public Command source.Reply(_("You are already identified.")); else { - EventReturn MOD_RESULT; - FOREACH_RESULT(I_OnCheckAuthentication, OnCheckAuthentication(this, &source, params, na ? na->nc->display : nick, pass)); - if (MOD_RESULT == EVENT_STOP) - return; - - if (!na) - source.Reply(NICK_X_NOT_REGISTERED, nick.c_str()); - else if (MOD_RESULT != EVENT_ALLOW) - { - Log(LOG_COMMAND, source, this) << "and failed to identify"; - source.Reply(PASSWORD_INCORRECT); - bad_password(u); - } - else - { - if (u->IsIdentified()) - Log(LOG_COMMAND, source, this) << "to log out of account " << u->Account()->display; - - Log(LOG_COMMAND, source, this) << "and identified for account " << na->nc->display; - source.Reply(_("Password accepted - you are now recognized.")); - u->Identify(na); - na->Release(); - } + NSIdentifyRequest *req = new NSIdentifyRequest(source, this, na ? na->nc->display : nick, pass); + FOREACH_MOD(I_OnCheckAuthentication, OnCheckAuthentication(source.GetUser(), req)); + req->Dispatch(); } return; } |
