summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-07-03 12:21:00 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-07-03 12:21:00 +0200
commitbee8625fbe375f55053d3709b72a2972fbf6ba84 (patch)
tree421b62eb48531705813bbe19232564900e4e7f7f
parent4332765b27b8b10e4f450bbdf8ddb50dc6cfca43 (diff)
Move calling the OnUserPreNick() hook and the restrictbannedusers check from core to cmd_nick (core_user)
-rw-r--r--src/coremods/core_user/cmd_nick.cpp22
-rw-r--r--src/users.cpp26
2 files changed, 22 insertions, 26 deletions
diff --git a/src/coremods/core_user/cmd_nick.cpp b/src/coremods/core_user/cmd_nick.cpp
index 1b25616dd..a28c40451 100644
--- a/src/coremods/core_user/cmd_nick.cpp
+++ b/src/coremods/core_user/cmd_nick.cpp
@@ -61,6 +61,28 @@ CmdResult CommandNick::HandleLocal(const std::vector<std::string>& parameters, L
return CMD_FAILURE;
}
+ ModResult MOD_RESULT;
+ FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (user, newnick));
+
+ // If a module denied the change, abort now
+ if (MOD_RESULT == MOD_RES_DENY)
+ return CMD_FAILURE;
+
+ // Disallow the nick change if <security:restrictbannedusers> is on and there is a ban matching this user in
+ // one of the channels they are on
+ if (ServerInstance->Config->RestrictBannedUsers)
+ {
+ for (UCListIter i = user->chans.begin(); i != user->chans.end(); ++i)
+ {
+ Channel* chan = (*i)->chan;
+ if (chan->GetPrefixValue(user) < VOICE_VALUE && chan->IsBanned(user))
+ {
+ user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str());
+ return CMD_FAILURE;
+ }
+ }
+ }
+
if (!user->ChangeNick(newnick, false))
return CMD_FAILURE;
diff --git a/src/users.cpp b/src/users.cpp
index 75852330f..47dbd2d22 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -619,32 +619,6 @@ bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
return false;
}
- LocalUser* const localuser = IS_LOCAL(this);
- if (!force && localuser)
- {
- ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnUserPreNick, MOD_RESULT, (localuser, newnick));
-
- // If a module denied the change, abort now
- if (MOD_RESULT == MOD_RES_DENY)
- return false;
-
- // Disallow the nick change if <security:restrictbannedusers> is on and there is a ban matching this user in
- // one of the channels they are on
- if (ServerInstance->Config->RestrictBannedUsers)
- {
- for (UCListIter i = this->chans.begin(); i != this->chans.end(); ++i)
- {
- Channel* chan = (*i)->chan;
- if (chan->GetPrefixValue(this) < VOICE_VALUE && chan->IsBanned(this))
- {
- this->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (you're banned)", chan->name.c_str());
- return false;
- }
- }
- }
- }
-
if (assign(newnick) == assign(nick))
{
// case change, don't need to check campers