From 42238034490fb5479d787bd1695750387d508200 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 24 Nov 2014 14:27:23 -0500 Subject: 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. --- modules/commands/os_login.cpp | 54 +++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'modules/commands/os_login.cpp') diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp index 02da958a7..8aae3c302 100644 --- a/modules/commands/os_login.cpp +++ b/modules/commands/os_login.cpp @@ -28,22 +28,33 @@ class CommandOSLogin : public Command User *u = source.GetUser(); Oper *o = source.nc->o; if (o == NULL) + { source.Reply(_("No oper block for your nickname.")); - else if (o->password.empty()) + return; + } + + if (o->GetPassword().empty()) + { source.Reply(_("Your oper block doesn't require logging in.")); - else if (u->HasExt("os_login")) + return; + } + + if (u->HasExtOK("os_login")) + { source.Reply(_("You are already logged in.")); - else if (o->password != password) + return; + } + + if (o->GetPassword() != password) { source.Reply(_("Password incorrect.")); u->BadPassword(); + return; } - else - { - Log(LOG_ADMIN, source, this) << "and successfully identified to " << source.service->nick; - u->Extend("os_login"); - source.Reply(_("Password accepted.")); - } + + Log(LOG_ADMIN, source, this) << "and successfully identified to " << source.service->nick; + u->Extend("os_login", true); + source.Reply(_("Password accepted.")); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -71,17 +82,26 @@ class CommandOSLogout : public Command User *u = source.GetUser(); Oper *o = source.nc->o; if (o == NULL) + { source.Reply(_("No oper block for your nick.")); - else if (o->password.empty()) + return; + } + + if (o->GetPassword().empty()) + { source.Reply(_("Your oper block doesn't require logging in.")); - else if (!u->HasExt("os_login")) - source.Reply(_("You are not identified.")); - else + return; + } + + if (!u->HasExtOK("os_login")) { - Log(LOG_ADMIN, source, this); - u->Shrink("os_login"); - source.Reply(_("You have been logged out.")); + source.Reply(_("You are not identified.")); + return; } + + Log(LOG_ADMIN, source, this); + u->ShrinkOK("os_login"); + source.Reply(_("You have been logged out.")); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -115,7 +135,7 @@ class OSLogin : public Module EventReturn IsServicesOper(User *u) override { - if (!u->Account()->o->password.empty()) + if (!u->Account()->o->GetPassword().empty()) { if (os_login.HasExt(u)) return EVENT_ALLOW; -- cgit