diff options
| author | 2022-12-10 14:14:37 +0000 | |
|---|---|---|
| committer | 2022-12-10 14:14:37 +0000 | |
| commit | b47b791f9f230527a7906e6e017f50e9f1c945aa (patch) | |
| tree | 468cf063c29a08bd899b4000b9d3eb6aedb11180 /src/modules/m_account.cpp | |
| parent | Remove support for the old deprecated Intel compiler. (diff) | |
Allow restricting an oper account based on services account.
Diffstat (limited to 'src/modules/m_account.cpp')
| -rw-r--r-- | src/modules/m_account.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/modules/m_account.cpp b/src/modules/m_account.cpp index 778a47bf1..3c446dffc 100644 --- a/src/modules/m_account.cpp +++ b/src/modules/m_account.cpp @@ -338,6 +338,28 @@ public: return MOD_RES_PASSTHRU; } + ModResult OnPreOperLogin(LocalUser* user, const std::shared_ptr<OperAccount>& oper) override + { + const std::string accountstr = oper->GetConfig()->getString("account"); + if (accountstr.empty()) + return MOD_RES_PASSTHRU; + + const std::string* accountid = accountapi.GetAccountId(user); + const std::string* accountname = accountapi.GetAccountName(user); + + irc::spacesepstream accountstream(accountstr); + for (std::string account; accountstream.GetToken(account); ) + { + if (accountid && irc::equals(account, *accountid)) + return MOD_RES_PASSTHRU; // Matches on account id. + + if (accountname && irc::equals(account, *accountname)) + return MOD_RES_PASSTHRU; // Matches on account name. + } + + return MOD_RES_DENY; // Account required but it does not match. + } + ModResult OnSetConnectClass(LocalUser* user, const ConnectClass::Ptr& myclass) override { const char* error = nullptr; |
