summaryrefslogtreecommitdiff
path: root/modules/commands/ns_resetpass.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
committerAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
commit42238034490fb5479d787bd1695750387d508200 (patch)
treec93c62e0e1c936e656ae5b9ee1b62380ce2a194c /modules/commands/ns_resetpass.cpp
parentd492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff)
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most object relationships implicitly defined, and use the graph to trace references between objects to determine relationships. Edges may also be marked as having a dependency of the object they point to, which allows for automatic cleanup and deletion of most objects when no longer needed. Additionally, this allows not having to require in-memory copies of everything when using external databases. db_sql has been rewritten for this and now always requires a database to function. db_sql with MySQL now requires InnoDB to make use of transactions and foreign key constraints.
Diffstat (limited to 'modules/commands/ns_resetpass.cpp')
-rw-r--r--modules/commands/ns_resetpass.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp
index d89d16f3d..a1c32976c 100644
--- a/modules/commands/ns_resetpass.cpp
+++ b/modules/commands/ns_resetpass.cpp
@@ -11,7 +11,7 @@
#include "module.h"
-static bool SendResetEmail(User *u, const NickServ::Nick *na, BotInfo *bi);
+static bool SendResetEmail(User *u, NickServ::Nick *na, ServiceBot *bi);
class CommandNSResetPass : public Command
{
@@ -25,7 +25,7 @@ class CommandNSResetPass : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) override
{
- const NickServ::Nick *na = NickServ::FindNick(params[0]);
+ NickServ::Nick *na = NickServ::FindNick(params[0]);
if (!na)
{
@@ -33,7 +33,7 @@ class CommandNSResetPass : public Command
return;
}
- if (!na->nc->email.equals_ci(params[1]))
+ if (!na->GetAccount()->GetEmail().equals_ci(params[1]))
{
source.Reply(_("Incorrect email address."));
return;
@@ -41,8 +41,8 @@ class CommandNSResetPass : public Command
if (SendResetEmail(source.GetUser(), na, source.service))
{
- Log(LOG_COMMAND, source, this) << "for " << na->nick << " (group: " << na->nc->display << ")";
- source.Reply(_("Password reset email for \002{0}\002 has been sent."), na->nick);
+ Log(LOG_COMMAND, source, this) << "for " << na->GetNick() << " (group: " << na->GetAccount()->GetDisplay() << ")";
+ source.Reply(_("Password reset email for \002{0}\002 has been sent."), na->GetNick());
}
}
@@ -63,7 +63,7 @@ class NSResetPass : public Module
, public EventHook<Event::PreCommand>
{
CommandNSResetPass commandnsresetpass;
- PrimitiveExtensibleItem<ResetInfo> reset;
+ ExtensibleItem<ResetInfo> reset;
public:
NSResetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR)
@@ -86,10 +86,10 @@ class NSResetPass : public Module
NickServ::Nick *na = NickServ::FindNick(params[0]);
- ResetInfo *ri = na ? reset.Get(na->nc) : NULL;
+ ResetInfo *ri = na ? reset.Get(na->GetAccount()) : NULL;
if (na && ri)
{
- NickServ::Account *nc = na->nc;
+ NickServ::Account *nc = na->GetAccount();
const Anope::string &passcode = params[1];
if (ri->time < Anope::CurTime - 3600)
{
@@ -99,14 +99,14 @@ class NSResetPass : public Module
else if (passcode.equals_cs(ri->code))
{
reset.Unset(nc);
- nc->Shrink<bool>("UNCONFIRMED");
+ nc->UnsetS<bool>("UNCONFIRMED");
- Log(LOG_COMMAND, source, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify as " << na->nick;
+ Log(LOG_COMMAND, source, &commandnsresetpass) << "confirmed RESETPASS to forcefully identify as " << na->GetNick();
if (source.GetUser())
{
source.GetUser()->Identify(na);
- source.Reply(_("You are now identified for \002{0}\002. Change your password now."), na->nc->display);
+ source.Reply(_("You are now identified for \002{0}\002. Change your password now."), na->GetAccount()->GetDisplay());
}
}
else
@@ -120,25 +120,23 @@ class NSResetPass : public Module
}
};
-static bool SendResetEmail(User *u, const NickServ::Nick *na, BotInfo *bi)
+static bool SendResetEmail(User *u, NickServ::Nick *na, ServiceBot *bi)
{
- Anope::string subject = Language::Translate(na->nc, Config->GetBlock("mail")->Get<const Anope::string>("reset_subject").c_str()),
- message = Language::Translate(na->nc, Config->GetBlock("mail")->Get<const Anope::string>("reset_message").c_str()),
+ Anope::string subject = Language::Translate(na->GetAccount(), Config->GetBlock("mail")->Get<const Anope::string>("reset_subject").c_str()),
+ message = Language::Translate(na->GetAccount(), Config->GetBlock("mail")->Get<const Anope::string>("reset_message").c_str()),
passcode = Anope::Random(20);
- subject = subject.replace_all_cs("%n", na->nick);
+ subject = subject.replace_all_cs("%n", na->GetNick());
subject = subject.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
subject = subject.replace_all_cs("%c", passcode);
- message = message.replace_all_cs("%n", na->nick);
+ message = message.replace_all_cs("%n", na->GetNick());
message = message.replace_all_cs("%N", Config->GetBlock("networkinfo")->Get<const Anope::string>("networkname"));
message = message.replace_all_cs("%c", passcode);
- ResetInfo *ri = na->nc->Extend<ResetInfo>("reset");
- ri->code = passcode;
- ri->time = Anope::CurTime;
+ na->GetAccount()->Extend<ResetInfo>("reset", ResetInfo{passcode, Anope::CurTime});
- return Mail::Send(u, na->nc, bi, subject, message);
+ return Mail::Send(u, na->GetAccount(), bi, subject, message);
}
MODULE_INIT(NSResetPass)