summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-03-05 17:23:22 -0500
committerAdam <Adam@anope.org>2011-03-05 17:23:22 -0500
commit6fe2d8af973dfb0c81f513e56488e39a4eea2fbf (patch)
tree432b93053ef56d1ff98b3193d5768a4ca16d3785 /modules
parent90e5d0feaa1646c28cfce45dbde1a914a6f1d62c (diff)
Removed nickrequests, instead have unconfirmed registrations. Also made ns_resetpass allow remote-id to get past things such as kill immed.
Diffstat (limited to 'modules')
-rw-r--r--modules/core/cs_register.cpp8
-rw-r--r--modules/core/db_plain.cpp43
-rw-r--r--modules/core/ns_drop.cpp25
-rw-r--r--modules/core/ns_getpass.cpp11
-rw-r--r--modules/core/ns_group.cpp9
-rw-r--r--modules/core/ns_identify.cpp20
-rw-r--r--modules/core/ns_info.cpp33
-rw-r--r--modules/core/ns_list.cpp92
-rw-r--r--modules/core/ns_register.cpp315
-rw-r--r--modules/core/ns_resetpass.cpp51
-rw-r--r--modules/core/ns_set_email.cpp80
-rw-r--r--modules/extra/db_mysql.cpp31
-rw-r--r--modules/extra/m_ldap.cpp6
-rw-r--r--modules/extra/m_mysql.cpp2
-rw-r--r--modules/extra/ns_identify_ldap.cpp2
-rw-r--r--modules/protocol/bahamut.cpp3
-rw-r--r--modules/protocol/inspircd11.cpp3
-rw-r--r--modules/protocol/inspircd12.cpp2
-rw-r--r--modules/protocol/inspircd20.cpp2
-rw-r--r--modules/protocol/plexus.cpp2
-rw-r--r--modules/protocol/unreal32.cpp6
21 files changed, 321 insertions, 425 deletions
diff --git a/modules/core/cs_register.cpp b/modules/core/cs_register.cpp
index 34cdc50df..1f1c6e9b2 100644
--- a/modules/core/cs_register.cpp
+++ b/modules/core/cs_register.cpp
@@ -32,12 +32,10 @@ class CommandCSRegister : public Command
Channel *c = findchan(chan);
if (readonly)
- {
source.Reply(_("Sorry, channel registration is temporarily disabled."));
- return MOD_CONT;
- }
-
- if (chan[0] == '&')
+ else if (u->Account()->HasFlag(NI_UNCONFIRMED))
+ source.Reply(_("You must confirm your account before you can register a channel."));
+ else if (chan[0] == '&')
source.Reply(_("Local channels cannot be registered."));
else if (chan[0] != '#')
source.Reply(_(CHAN_SYMBOL_REQUIRED));
diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp
index f47f3156a..4dbf864de 100644
--- a/modules/core/db_plain.cpp
+++ b/modules/core/db_plain.cpp
@@ -22,7 +22,6 @@ enum MDType
MD_NONE,
MD_NC,
MD_NA,
- MD_NR,
MD_BI,
MD_CH
};
@@ -52,7 +51,6 @@ static void ReadDatabase(Module *m = NULL)
NickCore *nc = NULL;
NickAlias *na = NULL;
- NickRequest *nr = NULL;
BotInfo *bi = NULL;
ChannelInfo *ci = NULL;
@@ -100,11 +98,6 @@ static void ReadDatabase(Module *m = NULL)
na = findnick(params[2]);
Type = MD_NA;
}
- else if (params[0].equals_ci("NR"))
- {
- nr = findrequestnick(params[1]);
- Type = MD_NR;
- }
else if (params[0].equals_ci("BI"))
{
bi = findbot(params[1]);
@@ -149,20 +142,6 @@ static void ReadDatabase(Module *m = NULL)
Log() << "[db_plain]: " << ex.GetReason();
}
}
- else if (Type == MD_NR && nr)
- {
- try
- {
- if (m)
- m->OnDatabaseReadMetadata(nr, key, params);
- else
- FOREACH_RESULT(I_OnDatabaseReadMetadata, OnDatabaseReadMetadata(nr, key, params));
- }
- catch (const DatabaseException &ex)
- {
- Log() << "[db_plain]: " << ex.GetReason();
- }
- }
else if (Type == MD_BI && bi)
{
try
@@ -292,17 +271,6 @@ static void LoadNickAlias(const std::vector<Anope::string> &params)
Log(LOG_DEBUG_2) << "[db_plain}: Loaded nickalias for " << na->nick;
}
-static void LoadNickRequest(const std::vector<Anope::string> &params)
-{
- NickRequest *nr = new NickRequest(params[0]);
- nr->passcode = params[1];
- nr->password = params[2];
- nr->email = params[3];
- nr->requested = params[4].is_pos_number_only() ? convertTo<time_t>(params[4]) : 0;
-
- Log(LOG_DEBUG_2) << "[db_plain]: Loaded nickrequest for " << nr->nick;
-}
-
static void LoadBotInfo(const std::vector<Anope::string> &params)
{
BotInfo *bi = findbot(params[0]);
@@ -480,8 +448,6 @@ class DBPlain : public Module
LoadNickCore(otherparams);
else if (key.equals_ci("NA"))
LoadNickAlias(otherparams);
- else if (key.equals_ci("NR"))
- LoadNickRequest(otherparams);
else if (key.equals_ci("BI"))
LoadBotInfo(otherparams);
else if (key.equals_ci("CH"))
@@ -765,15 +731,6 @@ class DBPlain : public Module
db_buffer << "VER 2" << endl;
- for (nickrequest_map::const_iterator it = NickRequestList.begin(), it_end = NickRequestList.end(); it != it_end; ++it)
- {
- NickRequest *nr = it->second;
-
- db_buffer << "NR " << nr->nick << " " << nr->passcode << " " << nr->password << " " << nr->email << " " << nr->requested << endl;
-
- FOREACH_MOD(I_OnDatabaseWriteMetadata, OnDatabaseWriteMetadata(WriteMetadata, nr));
- }
-
for (nickcore_map::const_iterator nit = NickCoreList.begin(), nit_end = NickCoreList.end(); nit != nit_end; ++nit)
{
NickCore *nc = nit->second;
diff --git a/modules/core/ns_drop.cpp b/modules/core/ns_drop.cpp
index e7edcd79a..33a18009d 100644
--- a/modules/core/ns_drop.cpp
+++ b/modules/core/ns_drop.cpp
@@ -36,30 +36,7 @@ class CommandNSDrop : public Command
NickAlias *na = findnick((u->Account() && !nick.empty() ? nick : u->nick));
if (!na)
{
- NickRequest *nr = findrequestnick(u->Account() && !nick.empty() ? nick : u->nick);
- if (nr && u->Account() && u->Account()->IsServicesOper())
- {
- Log(LOG_ADMIN, u, this) << "to drop nickname " << nr->nick << " (email: " << nr->email << ")";
- delete nr;
- source.Reply(_("Nickname \002%s\002 has been dropped."), nick.c_str());
- }
- else if (nr && !nick.empty())
- {
- int res = enc_check_password(nick, nr->password);
- if (res)
- {
- Log(LOG_COMMAND, u, this) << "to drop nick request " << nr->nick;
- source.Reply(_("Nickname \002%s\002 has been dropped."), nr->nick.c_str());
- delete nr;
- }
- else if (bad_password(u))
- return MOD_STOP;
- else
- source.Reply(_(PASSWORD_INCORRECT));
- }
- else
- source.Reply(_(NICK_NOT_REGISTERED));
-
+ source.Reply(_(NICK_NOT_REGISTERED));
return MOD_CONT;
}
diff --git a/modules/core/ns_getpass.cpp b/modules/core/ns_getpass.cpp
index fdd5f2cd0..b034e2ba4 100644
--- a/modules/core/ns_getpass.cpp
+++ b/modules/core/ns_getpass.cpp
@@ -27,18 +27,9 @@ class CommandNSGetPass : public Command
const Anope::string &nick = params[0];
Anope::string tmp_pass;
NickAlias *na;
- NickRequest *nr = NULL;
if (!(na = findnick(nick)))
- {
- if ((nr = findrequestnick(nick)))
- {
- Log(LOG_ADMIN, u, this) << "for " << nr->nick;
- source.Reply(_("Passcode for %s is \002%s\002."), nick.c_str(), nr->passcode.c_str());
- }
- else
- source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str());
- }
+ source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str());
else if (na->HasFlag(NS_FORBIDDEN))
source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str());
else if (Config->NSSecureAdmins && na->nc->IsServicesOper())
diff --git a/modules/core/ns_group.cpp b/modules/core/ns_group.cpp
index 4ab1d112c..e09a4325a 100644
--- a/modules/core/ns_group.cpp
+++ b/modules/core/ns_group.cpp
@@ -29,12 +29,6 @@ class CommandNSGroup : public Command
const Anope::string &nick = params[0];
Anope::string pass = params[1];
- if (Config->NSEmailReg && findrequestnick(u->nick))
- {
- source.Reply(_(NICK_REQUESTED));
- return MOD_CONT;
- }
-
if (readonly)
{
source.Reply(_("Sorry, nickname grouping is temporarily disabled."));
@@ -121,7 +115,8 @@ class CommandNSGroup : public Command
u->Login(na->nc);
FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target));
ircdproto->SetAutoIdentificationToken(u);
- u->SetMode(NickServ, UMODE_REGISTERED);
+ if (target->nc->HasFlag(NI_UNCONFIRMED) == false)
+ u->SetMode(NickServ, UMODE_REGISTERED);
Log(LOG_COMMAND, u, this) << "makes " << u->nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")";
source.Reply(_("You are now in the group of \002%s\002."), target->nick.c_str());
diff --git a/modules/core/ns_identify.cpp b/modules/core/ns_identify.cpp
index 45b189ca6..074adbb76 100644
--- a/modules/core/ns_identify.cpp
+++ b/modules/core/ns_identify.cpp
@@ -31,13 +31,7 @@ class CommandNSIdentify : public Command
NickAlias *na = findnick(nick), *this_na = findnick(u->nick);
if (!na)
- {
- NickRequest *nr = findrequestnick(nick);
- if (nr)
- source.Reply(_(NICK_IS_PREREG));
- else
- source.Reply(_(NICK_NOT_REGISTERED));
- }
+ source.Reply(_(NICK_NOT_REGISTERED));
else if (na->HasFlag(NS_FORBIDDEN))
source.Reply(_(NICK_X_FORBIDDEN), na->nick.c_str());
else if (na->nc->HasFlag(NI_SUSPENDED))
@@ -72,7 +66,7 @@ class CommandNSIdentify : public Command
ircdproto->SendAccountLogin(u, u->Account());
ircdproto->SetAutoIdentificationToken(u);
- if (this_na && this_na->nc == na->nc)
+ if (this_na && this_na->nc == na->nc && this_na->nc->HasFlag(NI_UNCONFIRMED) == false)
u->SetMode(NickServ, UMODE_REGISTERED);
u->UpdateHost();
@@ -86,7 +80,7 @@ class CommandNSIdentify : public Command
FOREACH_MOD(I_OnNickIdentify, OnNickIdentify(u));
- if (Config->NSForceEmail && u->Account() && u->Account()->email.empty())
+ if (Config->NSForceEmail && u->Account()->email.empty())
{
source.Reply(_("You must now supply an e-mail for your nick.\n"
"This e-mail will allow you to retrieve your password in\n"
@@ -96,6 +90,14 @@ class CommandNSIdentify : public Command
"any third-party person."), NickServ->nick.c_str());
}
+ if (u->Account()->HasFlag(NI_UNCONFIRMED))
+ {
+ source.Reply(_("Your email address is not confirmed. To confirm it, follow the instructions that were emailed to you when you registered."));
+ time_t time_registered = Anope::CurTime - na->time_registered;
+ if (Config->NSUnconfirmedExpire > time_registered)
+ source.Reply(_("Your account will expire, if not confirmed, in %s"), duration(u->Account(), Config->NSUnconfirmedExpire - time_registered).c_str());
+ }
+
check_memos(u);
}
}
diff --git a/modules/core/ns_info.cpp b/modules/core/ns_info.cpp
index 52326ddb6..0ac50d471 100644
--- a/modules/core/ns_info.cpp
+++ b/modules/core/ns_info.cpp
@@ -44,14 +44,7 @@ class CommandNSInfo : public Command
if (!na)
{
- NickRequest *nr = findrequestnick(nick);
- if (nr)
- {
- source.Reply(_(NICK_IS_PREREG));
- if (has_auspex)
- source.Reply(_(" E-mail address: %s"), nr->email.c_str());
- }
- else if (nickIsServices(nick, true))
+ if (nickIsServices(nick, true))
source.Reply(_("Nick \002%s\002 is part of this Network's Services."), nick.c_str());
else
source.Reply(_(NICK_X_NOT_REGISTERED), nick.c_str());
@@ -120,11 +113,11 @@ class CommandNSInfo : public Command
Anope::string optbuf;
- CheckOptStr(optbuf, NI_KILLPROTECT, GetString(u->Account(), _("Protection")).c_str(), na->nc);
- CheckOptStr(optbuf, NI_SECURE, GetString(u->Account(), _("Security")).c_str(), na->nc);
- CheckOptStr(optbuf, NI_PRIVATE, GetString(u->Account(), _("Private")).c_str(), na->nc);
- CheckOptStr(optbuf, NI_MSG, GetString(u->Account(), _("Message mode")).c_str(), na->nc);
- CheckOptStr(optbuf, NI_AUTOOP, GetString(u->Account(), _("Auto-op")).c_str(), na->nc);
+ CheckOptStr(optbuf, NI_KILLPROTECT, _("Protection"), na->nc);
+ CheckOptStr(optbuf, NI_SECURE, _("Security"), na->nc);
+ CheckOptStr(optbuf, NI_PRIVATE, _("Private"), na->nc);
+ CheckOptStr(optbuf, NI_MSG, _("Message mode"), na->nc);
+ CheckOptStr(optbuf, NI_AUTOOP, _("Auto-op"), na->nc);
source.Reply(_(NICK_INFO_OPTIONS), optbuf.empty() ? _("None") : optbuf.c_str());
@@ -136,13 +129,21 @@ class CommandNSInfo : public Command
source.Reply(_("This nickname is currently suspended"));
}
- if (na->HasFlag(NS_NO_EXPIRE))
- source.Reply(_("This nickname will not expire."));
+ if (na->nc->HasFlag(NI_UNCONFIRMED) == false)
+ {
+ if (na->HasFlag(NS_NO_EXPIRE))
+ source.Reply(_("This nickname will not expire."));
+ else
+ source.Reply(_("Expires on: %s"), do_strftime(na->last_seen + Config->NSExpire).c_str());
+ }
else
- source.Reply(_("Expires on: %s"), do_strftime(na->last_seen + Config->NSExpire).c_str());
+ source.Reply(_("Expires on: %s"), do_strftime(na->time_registered + Config->NSUnconfirmedExpire).c_str());
}
FOREACH_MOD(I_OnNickInfo, OnNickInfo(source, na, show_hidden));
+
+ if (na->nc->HasFlag(NI_UNCONFIRMED))
+ source.Reply(_("This nickname is unconfirmed."));
}
return MOD_CONT;
}
diff --git a/modules/core/ns_list.cpp b/modules/core/ns_list.cpp
index 1ecbad3d3..fb8673069 100644
--- a/modules/core/ns_list.cpp
+++ b/modules/core/ns_list.cpp
@@ -97,67 +97,53 @@ class CommandNSList : public Command
mync = u->Account();
source.Reply(_(LIST_HEADER), pattern.c_str());
- if (!unconfirmed)
+ for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
{
- for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
- {
- NickAlias *na = it->second;
-
- /* Don't show private and forbidden nicks to non-services admins. */
- if (na->HasFlag(NS_FORBIDDEN) && !is_servadmin)
- continue;
- if (na->nc->HasFlag(NI_PRIVATE) && !is_servadmin && na->nc != mync)
- continue;
- if (forbidden && !na->HasFlag(NS_FORBIDDEN))
+ NickAlias *na = it->second;
+
+ /* Don't show private and forbidden nicks to non-services admins. */
+ if (na->HasFlag(NS_FORBIDDEN) && !is_servadmin)
+ continue;
+ else if (na->nc->HasFlag(NI_PRIVATE) && !is_servadmin && na->nc != mync)
+ continue;
+ else if (forbidden && !na->HasFlag(NS_FORBIDDEN))
+ continue;
+ else if (nsnoexpire && !na->HasFlag(NS_NO_EXPIRE))
continue;
- else if (nsnoexpire && !na->HasFlag(NS_NO_EXPIRE))
- continue;
- else if (suspended && !na->nc->HasFlag(NI_SUSPENDED))
- continue;
-
- /* We no longer compare the pattern against the output buffer.
- * Instead we build a nice nick!user@host buffer to compare.
- * The output is then generated separately. -TheShadow */
- snprintf(buf, sizeof(buf), "%s!%s", na->nick.c_str(), !na->last_usermask.empty() && !na->HasFlag(NS_FORBIDDEN) ? na->last_usermask.c_str() : "*@*");
- if (na->nick.equals_ci(pattern) || Anope::Match(buf, pattern))
- {
- if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= Config->NSListMax)
- {
- if (is_servadmin && na->HasFlag(NS_NO_EXPIRE))
- noexpire_char = '!';
- else
- noexpire_char = ' ';
- if (na->nc->HasFlag(NI_HIDE_MASK) && !is_servadmin && na->nc != mync)
- snprintf(buf, sizeof(buf), "%-20s [Hostname Hidden]", na->nick.c_str());
- else if (na->HasFlag(NS_FORBIDDEN))
- snprintf(buf, sizeof(buf), "%-20s [Forbidden]", na->nick.c_str());
- else if (na->nc->HasFlag(NI_SUSPENDED))
- snprintf(buf, sizeof(buf), "%-20s [Suspended]", na->nick.c_str());
- else
- snprintf(buf, sizeof(buf), "%-20s %s", na->nick.c_str(), na->last_usermask.c_str());
- source.Reply(" %c%s", noexpire_char, buf);
- }
- ++count;
- }
- }
- }
-
- if (unconfirmed || is_servadmin)
- {
- noexpire_char = ' ';
-
- for (nickrequest_map::const_iterator it = NickRequestList.begin(), it_end = NickRequestList.end(); it != it_end; ++it)
+ else if (suspended && !na->nc->HasFlag(NI_SUSPENDED))
+ continue;
+ else if (unconfirmed && na->nc->HasFlag(NI_UNCONFIRMED))
+ continue;
+
+ /* We no longer compare the pattern against the output buffer.
+ * Instead we build a nice nick!user@host buffer to compare.
+ * The output is then generated separately. -TheShadow */
+ snprintf(buf, sizeof(buf), "%s!%s", na->nick.c_str(), !na->last_usermask.empty() && !na->HasFlag(NS_FORBIDDEN) ? na->last_usermask.c_str() : "*@*");
+ if (na->nick.equals_ci(pattern) || Anope::Match(buf, pattern))
{
- NickRequest *nr = it->second;
-
- snprintf(buf, sizeof(buf), "%s!*@*", nr->nick.c_str());
- if ((nr->nick.equals_ci(pattern) || Anope::Match(buf, pattern)) && ++nnicks <= Config->NSListMax)
+ if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nnicks <= Config->NSListMax)
{
- snprintf(buf, sizeof(buf), "%-20s [UNCONFIRMED]", nr->nick.c_str());
+ if (is_servadmin && na->HasFlag(NS_NO_EXPIRE))
+ noexpire_char = '!';
+ else
+ noexpire_char = ' ';
+ if (na->nc->HasFlag(NI_HIDE_MASK) && !is_servadmin && na->nc != mync)
+ snprintf(buf, sizeof(buf), "%-20s [Hostname Hidden]", na->nick.c_str());
+ else if (na->HasFlag(NS_FORBIDDEN))
+ snprintf(buf, sizeof(buf), "%-20s [Forbidden]", na->nick.c_str());
+ else if (na->nc->HasFlag(NI_SUSPENDED))
+ snprintf(buf, sizeof(buf), "%-20s [Suspended]", na->nick.c_str());
+ else if (na->nc->HasFlag(NI_UNCONFIRMED))
+ snprintf(buf, sizeof(buf), "%-20s [Unconfirmed]", na->nick.c_str());
+ else
+ snprintf(buf, sizeof(buf), "%-20s %s", na->nick.c_str(), na->last_usermask.c_str());
source.Reply(" %c%s", noexpire_char, buf);
}
+ ++count;
}
}
+
+
source.Reply(_("End of list - %d/%d matches shown."), nnicks > Config->NSListMax ? Config->NSListMax : nnicks, nnicks);
return MOD_CONT;
}
diff --git a/modules/core/ns_register.cpp b/modules/core/ns_register.cpp
index d7867896c..d336f1f4d 100644
--- a/modules/core/ns_register.cpp
+++ b/modules/core/ns_register.cpp
@@ -13,147 +13,67 @@
#include "module.h"
-static bool SendRegmail(User *u, NickRequest *nr);
+static bool SendRegmail(User *u, NickAlias *na);
class CommandNSConfirm : public Command
{
- protected:
- CommandReturn ActuallyConfirmNick(CommandSource &source, NickRequest *nr, bool force)
+ public:
+ CommandNSConfirm() : Command("CONFIRM", 1, 2)
{
- User *u = source.u;
- NickAlias *na = new NickAlias(nr->nick, new NickCore(nr->nick));
- Anope::string tmp_pass;
-
- na->nc->pass = nr->password;
-
- if (force)
- {
- na->last_usermask = "*@*";
- na->last_realname = "unknown";
- }
- else
- {
- Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
- na->last_usermask = last_usermask;
- na->last_realname = u->realname;
- if (Config->NSAddAccessOnReg)
- na->nc->AddAccess(create_mask(u));
- }
-
- if (!nr->email.empty())
- na->nc->email = nr->email;
-
- if (!force)
- {
- u->Login(na->nc);
- Log(LOG_COMMAND, u, this) << "to register " << nr->nick << " (email: " << (!nr->email.empty() ? nr->email : "none") << ")";
- if (Config->NSAddAccessOnReg)
- source.Reply(_("Nickname \002%s\002 registered under your account: %s"), u->nick.c_str(), na->nc->GetAccess(0).c_str());
- else
- source.Reply(_("Nickname \002%s\002 registered."), u->nick.c_str());
- delete nr;
-
- ircdproto->SendAccountLogin(u, u->Account());
- ircdproto->SetAutoIdentificationToken(u);
-
- if (enc_decrypt(na->nc->pass, tmp_pass) == 1)
- source.Reply(_("Your password is \002%s\002 - remember this for later use."), tmp_pass.c_str());
-
- u->lastnickreg = Anope::CurTime;
- }
- else
- {
- Log(LOG_COMMAND, u, this) << "to confirm " << nr->nick << " (email: " << (!nr->email.empty() ? nr->email : "none") << ")";
- source.Reply(_("Nickname \002%s\002 confirmed"), nr->nick.c_str());
- User *user = finduser(nr->nick);
- /* Delrequest must be called before validate_user */
- delete nr;
- if (user)
- validate_user(user);
- }
-
- FOREACH_MOD(I_OnNickRegister, OnNickRegister(na));
-
- return MOD_CONT;
+ this->SetFlag(CFLAG_ALLOW_UNREGISTERED);
+ this->SetDesc("Confirm an auth code");
}
- CommandReturn DoConfirm(CommandSource &source, const std::vector<Anope::string> &params)
+ CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
User *u = source.u;
- Anope::string passcode = !params.empty() ? params[0] : "";
+ const Anope::string &passcode = params[0];
- NickRequest *nr = findrequestnick(u->nick);
-
- if (Config->NSEmailReg)
+ if (u->Account() && u->Account()->HasPriv("nickserv/confirm"))
{
- if (passcode.empty())
- {
- this->OnSyntaxError(source, "");
- return MOD_CONT;
- }
-
- if (!nr)
+ NickAlias *na = findnick(passcode);
+ if (na == NULL)
+ source.Reply(_(NICK_X_NOT_REGISTERED), passcode.c_str());
+ else if (na->nc->HasFlag(NI_UNCONFIRMED) == false)
+ source.Reply(_("Nick \002%s\002 is already confirmed."), na->nick.c_str());
{
- if (u->Account() && u->Account()->HasPriv("nickserv/confirm"))
- {
- /* If an admin, their nick is obviously already regged, so look at the passcode to get the nick
- of the user they are trying to validate, and push that user through regardless of passcode */
- nr = findrequestnick(passcode);
- if (nr)
- {
- ActuallyConfirmNick(source, nr, true);
- return MOD_CONT;
- }
- }
- source.Reply(_("Registration step 1 may have expired, please use \"%R%s register <password> <email>\" first."), Config->s_NickServ.c_str());
-
- return MOD_CONT;
- }
-
- if (!nr->passcode.equals_cs(passcode))
- {
- source.Reply(_(NICK_CONFIRM_INVALID));
- return MOD_CONT;
+ na->nc->UnsetFlag(NI_UNCONFIRMED);
+ Log(LOG_ADMIN, u, this) << "to confirm nick " << na->nick << " (" << na->nc->display << ")";
+ source.Reply(_("Nick \002%s\002 has been confirmed."), na->nick.c_str());
}
}
-
- if (!nr)
+ else if (u->Account())
{
- source.Reply(_("Sorry, registration failed."));
- return MOD_CONT;
+ Anope::string code;
+ if (u->Account()->GetExtRegular<Anope::string>("ns_register_passcode", code) && code == passcode)
+ {
+ u->Account()->Shrink("ns_register_passcode");
+ Log(LOG_COMMAND, u, this) << "to confirm their email";
+ source.Reply(_("Your email address of \002%s\002 has been confirmed."), u->Account()->email.c_str());
+ u->Account()->UnsetFlag(NI_UNCONFIRMED);
+ }
+ else
+ source.Reply(_("Invalid passcode."));
}
+ else
+ source.Reply(_("Invalid passcode."));
- ActuallyConfirmNick(source, nr, false);
return MOD_CONT;
}
- public:
- CommandNSConfirm(const Anope::string &cmdn, int min, int max) : Command(cmdn, min, max)
- {
- this->SetFlag(CFLAG_ALLOW_UNREGISTERED);
- this->SetDesc("Confirm a nickserv auth code");
- }
-
- CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
- {
- return this->DoConfirm(source, params);
- }
-
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
{
User *u = source.u;
source.Reply(_("Syntax: \002CONFIRM \037passcode\037\002\n"
" \n"
- "This is the second step of nickname registration process.\n"
- "You must perform this command in order to get your nickname\n"
- "registered with %s. The passcode (or called auth code also)\n"
- "is sent to your e-mail address in the first step of the\n"
- "registration process. For more information about the first\n"
- "stage of the registration process, type: \002%R%s HELP REGISTER\002\n"
+ "This command is used by several commands as a way to confirm\n"
+ "changes made to your account.\n"
+ " \n"
+ "This is most commonly used to confirm your email address once\n"
+ "you register or change it.\n"
" \n"
"This is also used after the RESETPASS command has been used to\n"
- "force identify you to your nick so you may change your password."),
- NickServ->nick.c_str());
+ "force identify you to your nick so you may change your password."));
if (u->Account() && u->Account()->HasPriv("nickserv/confirm"))
source.Reply(_("Additionally, Services Operators with the \037nickserv/confirm\037 permission can\n"
"replace \037passcode\037 with a users nick to force validate them."));
@@ -166,10 +86,10 @@ class CommandNSConfirm : public Command
}
};
-class CommandNSRegister : public CommandNSConfirm
+class CommandNSRegister : public Command
{
public:
- CommandNSRegister() : CommandNSConfirm("REGISTER", 1, 2)
+ CommandNSRegister() : Command("REGISTER", 1, 2)
{
this->SetFlag(CFLAG_ALLOW_UNREGISTERED);
this->SetDesc("Register a nickname");
@@ -178,22 +98,11 @@ class CommandNSRegister : public CommandNSConfirm
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
User *u = source.u;
- NickRequest *nr = NULL, *anr = NULL;
NickAlias *na;
size_t prefixlen = Config->NSGuestNickPrefix.length();
size_t nicklen = u->nick.length();
Anope::string pass = params[0];
Anope::string email = params.size() > 1 ? params[1] : "";
- Anope::string passcode;
- int idx, min = 1, max = 62;
- int chars[] = {
- ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
- 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
- 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
- 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
- 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
- };
- std::list<std::pair<Anope::string, Anope::string> >::iterator it, it_end;
if (readonly)
{
@@ -207,12 +116,6 @@ class CommandNSRegister : public CommandNSConfirm
return MOD_CONT;
}
- if ((anr = findrequestnick(u->nick)))
- {
- source.Reply(_(NICK_REQUESTED));
- return MOD_CONT;
- }
-
/* Prevent "Guest" nicks from being registered. -TheShadow */
/* Guest nick can now have a series of between 1 and 7 digits.
@@ -231,7 +134,7 @@ class CommandNSRegister : public CommandNSConfirm
}
if (Config->RestrictOperNicks)
- for (it = Config->Opers.begin(), it_end = Config->Opers.end(); it != it_end; ++it)
+ for (std::list<std::pair<Anope::string, Anope::string> >::iterator it = Config->Opers.begin(), it_end = Config->Opers.end(); it != it_end; ++it)
{
Anope::string nick = it->first;
@@ -265,38 +168,46 @@ class CommandNSRegister : public CommandNSConfirm
source.Reply(_(MAIL_X_INVALID), email.c_str());
else
{
- for (idx = 0; idx < 9; ++idx)
- passcode += chars[1 + static_cast<int>((static_cast<float>(max - min)) * getrandom16() / 65536.0) + min];
- nr = new NickRequest(u->nick);
- nr->passcode = passcode;
- enc_encrypt(pass, nr->password);
+ na = new NickAlias(u->nick, new NickCore(u->nick));
+ enc_encrypt(pass, na->nc->pass);
if (!email.empty())
- nr->email = email;
- nr->requested = Anope::CurTime;
- FOREACH_MOD(I_OnMakeNickRequest, OnMakeNickRequest(nr));
+ na->nc->email = email;
+
+ Anope::string last_usermask = u->GetIdent() + "@" + u->GetDisplayedHost();
+ na->last_usermask = last_usermask;
+ na->last_realname = u->realname;
+ if (Config->NSAddAccessOnReg)
+ na->nc->AddAccess(create_mask(u));
+
+ u->Login(na->nc);
+
+ Log(LOG_COMMAND, u, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
+
+ FOREACH_MOD(I_OnNickRegister, OnNickRegister(na));
+
+ if (Config->NSAddAccessOnReg)
+ source.Reply(_("Nickname \002%s\002 registered under your account: %s"), u->nick.c_str(), na->nc->GetAccess(0).c_str());
+ else
+ source.Reply(_("Nickname \002%s\002 registered."), u->nick.c_str());
+
+ Anope::string tmp_pass;
+ if (enc_decrypt(na->nc->pass, tmp_pass) == 1)
+ source.Reply(_("Your password is \002%s\002 - remember this for later use."), tmp_pass.c_str());
+
if (Config->NSEmailReg)
{
- if (SendRegmail(u, nr))
+ na->nc->SetFlag(NI_UNCONFIRMED);
+ if (SendRegmail(u, na))
{
- source.Reply(_("A passcode has been sent to %s, please type %R%s confirm <passcode> to complete registration.\n"
- "If you need to cancel your registration, use \"%R%s drop <password>\"."),
- email.c_str(), Config->s_NickServ.c_str(), Config->s_NickServ.c_str());
-
- Log(LOG_COMMAND, u, this) << "send registration verification code to " << nr->email;
- }
- else
- {
- Log(LOG_COMMAND, u, this) << "unable to send registration verification mail";
- source.Reply(_("Nick NOT registered, please try again later."));
- delete nr;
- return MOD_CONT;
+ source.Reply(_("A passcode has been sent to %s, please type %R%s confirm <passcode> to confirm your email address."), email.c_str(), NickServ->nick.c_str());
+ source.Reply(_("If you do not confirm your email address within %s your account will expire."), duration(na->nc, Config->NSUnconfirmedExpire).c_str());
}
}
- else
- {
- std::vector<Anope::string> empty_params;
- return this->DoConfirm(source, empty_params);
- }
+
+ ircdproto->SendAccountLogin(u, u->Account());
+ ircdproto->SetAutoIdentificationToken(u);
+
+ u->lastnickreg = Anope::CurTime;
}
return MOD_CONT;
@@ -353,47 +264,54 @@ class CommandNSResend : public Command
public:
CommandNSResend() : Command("RESEND", 0, 0)
{
- this->SetFlag(CFLAG_ALLOW_UNREGISTERED);
- this->SetDesc("Resend a nickserv auth code");
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
+ if (!Config->NSEmailReg)
+ return MOD_CONT;
+
User *u = source.u;
- NickRequest *nr = NULL;
- if (Config->NSEmailReg)
+ NickAlias *na = findnick(u->nick);
+
+ if (na == NULL)
+ source.Reply(_(NICK_NOT_REGISTERED));
+ else if (na->nc != u->Account() || u->Account()->HasFlag(NI_UNCONFIRMED) == false)
+ source.Reply(_("Your account is already confirmed."));
+ else
{
- if ((nr = findrequestnick(u->nick)))
+ if (Anope::CurTime < u->Account()->lastmail + Config->NSResendDelay)
+ source.Reply(_("Cannot send mail now; please retry a little later."));
+ else if (!SendRegmail(u, na))
{
- if (Anope::CurTime < nr->lastmail + Config->NSResendDelay)
- {
- source.Reply(_("Cannot send mail now; please retry a little later."));
- return MOD_CONT;
- }
- if (!SendRegmail(u, nr))
- {
- nr->lastmail = Anope::CurTime;
- source.Reply(_("Your passcode has been re-sent to %s."), nr->email.c_str());
- Log(LOG_COMMAND, u, this) << "resend registration verification code for " << nr->nick;