summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2015-03-12 08:00:12 -0400
committerAdam <Adam@anope.org>2015-03-12 08:00:12 -0400
commitc5ff7c686837afbb854aa6546ade3aa8c86a1cd1 (patch)
tree34b29642844886068f3379ff999b1067b6a96750
parent92920f5a1c8866c8e26e1608f0feb3e3e54c8dd2 (diff)
Show passlen in PASSWORD_TOO_LONG
-rw-r--r--include/language.h2
-rw-r--r--modules/commands/ns_register.cpp6
-rw-r--r--modules/commands/ns_set.cpp15
3 files changed, 15 insertions, 8 deletions
diff --git a/include/language.h b/include/language.h
index a1b5c347d..7832f4692 100644
--- a/include/language.h
+++ b/include/language.h
@@ -74,7 +74,7 @@ namespace Language
#define MORE_OBSCURE_PASSWORD _("Please try again with a more obscure password. Passwords should be at least\n" \
"five characters long, should not be something easily guessed\n" \
"(e.g. your real name or your nick), and cannot contain the space or tab characters.")
-#define PASSWORD_TOO_LONG _("Your password is too long. Please try again with a shorter password.")
+#define PASSWORD_TOO_LONG _("Your password is too long. It must not exceed %u characters.")
#define NICK_NOT_REGISTERED _("Your nick isn't registered.")
#define NICK_X_NOT_REGISTERED _("Nick \002%s\002 isn't registered.")
#define NICK_X_NOT_IN_USE _("Nick \002%s\002 isn't currently in use.")
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index 4793b2269..75ef5a9fb 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -170,6 +170,8 @@ class CommandNSRegister : public Command
}
}
+ unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32");
+
if (Config->GetModule("nickserv")->Get<bool>("forceemail", "yes") && email.empty())
this->OnSyntaxError(source, "");
else if (u && Anope::CurTime < u->lastnickreg + reg_delay)
@@ -178,8 +180,8 @@ class CommandNSRegister : public Command
source.Reply(NICK_ALREADY_REGISTERED, u_nick.c_str());
else if (pass.equals_ci(u_nick) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && pass.length() < 5))
source.Reply(MORE_OBSCURE_PASSWORD);
- else if (pass.length() > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"))
- source.Reply(PASSWORD_TOO_LONG);
+ else if (pass.length() > passlen)
+ source.Reply(PASSWORD_TOO_LONG, passlen);
else if (!email.empty() && !Mail::Validate(email))
source.Reply(MAIL_X_INVALID, email.c_str());
else
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index fdf2a5e38..e8e7c335c 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -133,9 +133,11 @@ class CommandNSSetPassword : public Command
source.Reply(MORE_OBSCURE_PASSWORD);
return;
}
- else if (len > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"))
+
+ unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32");
+ if (len > passlen)
{
- source.Reply(PASSWORD_TOO_LONG);
+ source.Reply(PASSWORD_TOO_LONG, passlen);
return;
}
@@ -191,14 +193,17 @@ class CommandNSSASetPassword : public Command
source.Reply(_("You may not change the password of other Services Operators."));
return;
}
- else if (nc->display.equals_ci(params[1]) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5))
+
+ if (nc->display.equals_ci(params[1]) || (Config->GetBlock("options")->Get<bool>("strictpasswords") && len < 5))
{
source.Reply(MORE_OBSCURE_PASSWORD);
return;
}
- else if (len > Config->GetModule("nickserv")->Get<unsigned>("passlen", "32"))
+
+ unsigned int passlen = Config->GetModule("nickserv")->Get<unsigned>("passlen", "32");
+ if (len > passlen)
{
- source.Reply(PASSWORD_TOO_LONG);
+ source.Reply(PASSWORD_TOO_LONG, passlen);
return;
}