From 101e12833dd825f59b249396515b1410eb699557 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 18 Oct 2022 11:17:03 +0100 Subject: Allow requiring users to be logged into their nick for requireaccount. --- src/modules/m_account.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/modules/m_account.cpp') diff --git a/src/modules/m_account.cpp b/src/modules/m_account.cpp index dd696f5fa..9c042e439 100644 --- a/src/modules/m_account.cpp +++ b/src/modules/m_account.cpp @@ -340,10 +340,22 @@ public: ModResult OnSetConnectClass(LocalUser* user, ConnectClass::Ptr myclass) override { - if (myclass->config->getBool("requireaccount") && !accountapi.GetAccountName(user)) + const char* error = nullptr; + if (stdalgo::string::equalsci(myclass->config->getString("requireaccount"), "nick")) { - ServerInstance->Logs.Debug("CONNECTCLASS", "The %s connect class is not suitable as it requires the user to be logged into an account", - myclass->GetName().c_str()); + if (!accountapi.GetAccountName(user) && !accountapi.IsIdentifiedToNick(user)) + error = "an account matching their current nickname"; + } + else if (myclass->config->getBool("requireaccount")) + { + if (!accountapi.GetAccountName(user)) + error = "an account"; + } + + if (error) + { + ServerInstance->Logs.Debug("CONNECTCLASS", "The %s connect class is not suitable as it requires the user to be logged into %s", + myclass->GetName().c_str(), error); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; -- cgit v1.3.1-10-gc9f91