From d56e1a1d586d61cfee2cdb8f6e8ecd71428385d8 Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 25 Feb 2009 02:54:04 +0000 Subject: Allow accountname to be changed without an explicit unset git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11149 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_services_account.cpp | 50 ++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 6789d26d8..a763e8e68 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -320,37 +320,29 @@ class ModuleServicesAccount : public Module { User* dest = (User*)target; - /* logging them out? */ - if (extdata.empty()) - { - std::string* account; - dest->GetExt("accountname", account); - if (account) - { - dest->Shrink("accountname"); - delete account; - } + std::string* account; + if (dest->GetExt("accountname", account)) { + // remove old account so that we can set new (or leave unset) + dest->Shrink("accountname"); + delete account; } - else + + if (!extdata.empty()) { - // if they dont already have an accountname field, accept the remote server's - std::string* text; - if (!dest->GetExt("accountname", text)) - { - text = new std::string(extdata); - // remove any accidental leading/trailing spaces - trim(*text); - dest->Extend("accountname", text); - - if (IS_LOCAL(dest)) - dest->WriteNumeric(900, "%s %s %s :You are now logged in as %s", dest->nick.c_str(), dest->GetFullHost().c_str(), text->c_str(), text->c_str()); - - AccountData ac; - ac.user = dest; - ac.account = *text; - Event n((char*)&ac, this, "account_login"); - n.Send(ServerInstance); - } + account = new std::string(extdata); + // remove any accidental leading/trailing spaces + trim(*account); + dest->Extend("accountname", account); + + if (IS_LOCAL(dest)) + dest->WriteNumeric(900, "%s %s %s :You are now logged in as %s", + dest->nick.c_str(), dest->GetFullHost().c_str(), account->c_str(), account->c_str()); + + AccountData ac; + ac.user = dest; + ac.account = *account; + Event n((char*)&ac, this, "account_login"); + n.Send(ServerInstance); } } } -- cgit v1.2.3