Mercurial > prosody-hg
comparison 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 |
| parents | bba71bfe2154 |
| children | a0ad62a269df 97b3ca502547 |
comparison
equal
deleted
inserted
replaced
| 8191:d43012448c1f | 8192:4354f556c5db |
|---|---|
| 201 session:close{ condition = "not-authorized", text = "Account deleted" }; | 201 session:close{ condition = "not-authorized", text = "Account deleted" }; |
| 202 end | 202 end |
| 203 end | 203 end |
| 204 end, 200); | 204 end, 200); |
| 205 | 205 |
| 206 module:hook_global("user-password-changed", function(event) | |
| 207 local username, host, resource = event.username, event.host, event.resource; | |
| 208 local user = hosts[host].sessions[username]; | |
| 209 if user and user.sessions then | |
| 210 for r, session in pairs(user.sessions) do | |
| 211 if r ~= resource then | |
| 212 session:close{ condition = "reset", text = "Password changed" }; | |
| 213 end | |
| 214 end | |
| 215 end | |
| 216 end, 200); | |
| 217 | |
| 206 --- Port listener | 218 --- Port listener |
| 207 function listener.onconnect(conn) | 219 function listener.onconnect(conn) |
| 208 local session = sm_new_session(conn); | 220 local session = sm_new_session(conn); |
| 209 sessions[conn] = session; | 221 sessions[conn] = session; |
| 210 | 222 |
