Software /
code /
prosody
Diff
plugins/mod_c2s.lua @ 8192:4354f556c5db
core.usermanager, various modules: Disconnect other resources on password change (thanks waqas) (fixes #512)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 28 Jul 2017 13:15:29 +0200 |
parent | 7955:bba71bfe2154 |
child | 8201:a0ad62a269df |
child | 8234:97b3ca502547 |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Sun Aug 06 13:27:47 2017 +0200 +++ b/plugins/mod_c2s.lua Fri Jul 28 13:15:29 2017 +0200 @@ -203,6 +203,18 @@ 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);