diff options
| author | 2012-06-12 04:54:27 -0700 | |
|---|---|---|
| committer | 2012-06-12 04:54:27 -0700 | |
| commit | 911ed5cf15ea5eb0ff06bb6c9bfb4ceab8bf5489 (patch) | |
| tree | 97c3260d7a6d79733e06d19d5ddf5fde6ccf9d43 /src | |
| parent | Merge pull request #192 from attilamolnar/insp12+chopfix (diff) | |
| parent | Fix /NICK 0 not working on registration, allow changing to uid using /NICK <uid> (diff) | |
Merge pull request #189 from attilamolnar/insp12+nick0fix
[1.2] Fix /NICK 0 not working on registration
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands/cmd_nick.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/src/commands/cmd_nick.cpp b/src/commands/cmd_nick.cpp index e41ccd609..9a3f2705b 100644 --- a/src/commands/cmd_nick.cpp +++ b/src/commands/cmd_nick.cpp @@ -45,25 +45,45 @@ CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User return CMD_FAILURE; } - if (((!ServerInstance->IsNick(parameters[0].c_str(), ServerInstance->Config->Limits.NickMax))) && (IS_LOCAL(user))) + if ((IS_LOCAL(user)) && (!allowinvalid) && (!ServerInstance->IsNick(parameters[0].c_str(), ServerInstance->Config->Limits.NickMax)) && (parameters[0] != user->uuid)) { - if (!allowinvalid) + if (parameters[0] == "0") { - if (parameters[0] == "0") + // Special case, fake a /nick UIDHERE. Useful for evading "ERR: NICK IN USE" on connect etc. + if (user->registered & REG_NICK) { - // Special case, Fake a /nick UIDHERE. Useful for evading "ERR: NICK IN USE" on connect etc. + /* The user has either registered OR still in the registration phase but already sent + * at least one NICK that changed his nick from his uuid (see below). + * Pretend him doing a NICK <uuid>. + */ std::vector<std::string> p2; - std::deque<classbase*> dummy; p2.push_back(user->uuid); - this->HandleInternal(1, dummy); - this->Handle(p2, user); - this->HandleInternal(0, dummy); - return CMD_SUCCESS; + allowinvalid = true; + CmdResult result = this->Handle(p2, user); + allowinvalid = false; + return result; } + else + { + /* If the user hasn't registered yet and wants to register with his UID, allow him. + * By default every user gets his uuid as his nick even without sending any commands, + * that means in this case it's enough to just flip the REG_NICK bit. + */ - user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),parameters[0].c_str()); - return CMD_FAILURE; + user->registered |= REG_NICK; + if (user->registered == REG_NICKUSER) + { + int MOD_RESULT = 0; + FOREACH_RESULT(I_OnUserRegister,OnUserRegister(user)); + if (MOD_RESULT > 0) + return CMD_FAILURE; + } + return CMD_SUCCESS; + } } + + user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),parameters[0].c_str()); + return CMD_FAILURE; } if (assign(user->nick) == parameters[0]) |
