summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-03-13 09:02:31 -0500
committerAdam <Adam@anope.org>2013-03-13 09:02:31 -0500
commit72aa27ede5f265fe976f8e9935239aed9930ff3a (patch)
treece40f542624217c02e70fe0947a4fa925146f1a7
parent05223dbe6deee103b479f8b5e83a24d756edc511 (diff)
Allow m_ldap_authentication to block email changes if emails are controlled by ldap, don't tell users they must change their email during initial user registration
-rw-r--r--data/modules.example.conf12
-rw-r--r--modules/extra/m_ldap_authentication.cpp23
2 files changed, 25 insertions, 10 deletions
diff --git a/data/modules.example.conf b/data/modules.example.conf
index fea868c02..8d1ba902b 100644
--- a/data/modules.example.conf
+++ b/data/modules.example.conf
@@ -247,10 +247,16 @@ m_ldap_authentication
disable_ns_register = false
/*
- * The reason to give the users who try to "/msg NickServ REGISTER" if
- * disable_ns_register is enabled.
+ * If set, the reason to give the users who try to "/msg NickServ REGISTER".
+ * If not set, then registration is not blocked.
+ */
+ #disable_register_reason = "To register on this network visit http://some.misconfigured.site/register"
+
+ /*
+ * If set, the reason to give the users who try to "/msg NickServ SET EMAIL".
+ * If not set, then email changing is not blocked.
*/
- #disable_reason = "To register on this network, visit http://some.misconfigured.site/register"
+ #disable_email_reason = "To change your email address visit http://some.misconfigured.site"
}
/*
diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp
index a605fcb74..5ddd9da2d 100644
--- a/modules/extra/m_ldap_authentication.cpp
+++ b/modules/extra/m_ldap_authentication.cpp
@@ -212,8 +212,8 @@ class NSIdentifyLDAP : public Module
OnRegisterInterface orinterface;
Anope::string password_attribute;
- bool disable_register;
- Anope::string disable_reason;
+ Anope::string disable_register_reason;
+ Anope::string disable_email_reason;
public:
NSIdentifyLDAP(const Anope::string &modname, const Anope::string &creator) :
Module(modname, creator, SUPPORTED), ldap("LDAPProvider", "ldap/main"), iinterface(this), oninterface(this), orinterface(this)
@@ -239,15 +239,24 @@ class NSIdentifyLDAP : public Module
username_attribute = config.ReadValue("m_ldap_authentication", "username_attribute", "", 0);
this->password_attribute = config.ReadValue("m_ldap_authentication", "password_attribute", "", 0);
email_attribute = config.ReadValue("m_ldap_authentication", "email_attribute", "", 0);
- this->disable_register = config.ReadFlag("m_ldap_authentication", "disable_ns_register", "false", 0);
- this->disable_reason = config.ReadValue("m_ldap_authentication", "disable_reason", "", 0);
+ this->disable_register_reason = config.ReadValue("m_ldap_authentication", "disable_register_reason", "", 0);
+ this->disable_email_reason = config.ReadValue("m_ldap_authentication", "disable_email_reason", "", 0);
+
+ if (!email_attribute.empty())
+ /* Don't complain to users about how they need to update their email, we will do it for them */
+ Config->NSForceEmail = false;
}
EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> &params) anope_override
{
- if (this->disable_register && !this->disable_reason.empty() && command->name == "nickserv/register")
+ if (!this->disable_register_reason.empty() && command->name == "nickserv/register")
+ {
+ source.Reply(this->disable_register_reason);
+ return EVENT_STOP;
+ }
+ else if (!email_attribute.empty() && !this->disable_email_reason.empty() && command->name == "nickserv/set/email")
{
- source.Reply(_(this->disable_reason.c_str()));
+ source.Reply(this->disable_email_reason);
return EVENT_STOP;
}
@@ -294,7 +303,7 @@ class NSIdentifyLDAP : public Module
void OnNickRegister(NickAlias *na) anope_override
{
- if (this->disable_register || !this->ldap)
+ if (!this->disable_register_reason.empty() || !this->ldap)
return;
try