diff --git a/chat.js b/chat.js index 6e5be11862..fcfd87da70 100644 --- a/chat.js +++ b/chat.js @@ -166,6 +166,12 @@ Chat.hostfilter = function (host, user, connection) { filter(host, user, connection); } }; +Chat.loginfilters = []; +Chat.loginfilter = function (user, oldUser, usertype) { + for (const filter of Chat.loginfilters) { + filter(user, oldUser, usertype); + } +}; /********************************************************* * Parser @@ -977,6 +983,7 @@ Chat.loadPlugins = function () { if (Config.chatfilter) Chat.filters.push(Config.chatfilter); if (Config.namefilter) Chat.namefilters.push(Config.namefilter); if (Config.hostfilter) Chat.hostfilters.push(Config.hostfilter); + if (Config.loginfilter) Chat.loginfilters.push(Config.loginfilter); // Install plug-in commands and chat filters @@ -994,6 +1001,7 @@ Chat.loadPlugins = function () { if (plugin.chatfilter) Chat.filters.push(plugin.chatfilter); if (plugin.namefilter) Chat.namefilters.push(plugin.namefilter); if (plugin.hostfilter) Chat.hostfilters.push(plugin.hostfilter); + if (plugin.loginfilter) Chat.loginfilters.push(plugin.loginfilter); } }; diff --git a/users.js b/users.js index a488a72c92..f23dc6fec3 100644 --- a/users.js +++ b/users.js @@ -762,14 +762,14 @@ class User { if (user.namelocked) user.named = true; Rooms.global.checkAutojoin(user); - if (Config.loginfilter) Config.loginfilter(user, this, userType); + Chat.loginfilter(user, this, userType); return true; } // rename success if (this.forceRename(name, registered)) { Rooms.global.checkAutojoin(this); - if (Config.loginfilter) Config.loginfilter(this, null, userType); + Chat.loginfilter(this, null, userType); return true; } return false;