Allow requiring users to be logged into their nick for requireaccount.

This commit is contained in:
Sadie Powell 2022-10-18 11:17:03 +01:00
parent 3d660b8e49
commit 101e12833d
2 changed files with 17 additions and 3 deletions

View File

@ -339,6 +339,8 @@
# NOTE: You must complete the signon prior to full connection. Currently,
# this is only possible by using SASL authentication; passforward
# and PRIVMSG NickServ happen after your final connect block has been found.
# You can also set this to "nick" to require that users are logged into their
# current nickname.
# Requires the account module to be loaded.
#requireaccount="yes"

View File

@ -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;