diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-02-25 02:54:04 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-02-25 02:54:04 +0000 |
commit | d56e1a1d586d61cfee2cdb8f6e8ecd71428385d8 (patch) | |
tree | 755752df6552740ea32ea8f36ec17fc58bf838e1 | |
parent | 37671dc1cca9d6699d07d7a0e25dc9a6d6142e2c (diff) |
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
-rw-r--r-- | src/modules/m_services_account.cpp | 50 |
1 files 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); } } } |