From 73b75571e6546448dac8a67c6c231c14851ccac1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 28 Jul 2017 13:15:29 +0200 Subject: core.usermanager, various modules: Disconnect other resources on password change (thanks waqas) (fixes #512) --- plugins/mod_c2s.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'plugins/mod_c2s.lua') diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index cfeb0f0e..fbc22be6 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -203,6 +203,18 @@ module:hook_global("user-deleted", function(event) end end, 200); +module:hook_global("user-password-changed", function(event) + local username, host, resource = event.username, event.host, event.resource; + local user = hosts[host].sessions[username]; + if user and user.sessions then + for r, session in pairs(user.sessions) do + if r ~= resource then + session:close{ condition = "reset", text = "Password changed" }; + end + end + end +end, 200); + --- Port listener function listener.onconnect(conn) local session = sm_new_session(conn); -- cgit v1.2.3