Software /
code /
prosody
Comparison
plugins/mod_c2s.lua @ 5097:6c52a7a881cc
mod_c2s: When a user gets deleted, drop all their sessions
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 25 Aug 2012 01:28:38 +0200 |
parent | 5013:ab693eea0869 |
child | 5120:bcabea740c00 |
comparison
equal
deleted
inserted
replaced
5096:50a64fd79c07 | 5097:6c52a7a881cc |
---|---|
167 conn:close(); | 167 conn:close(); |
168 end | 168 end |
169 end | 169 end |
170 end | 170 end |
171 | 171 |
172 module:hook_global("user-deleted", function(event) | |
173 local username, host = event.username, event.host; | |
174 local user = hosts[host].sessions[username]; | |
175 if user and user.sessions then | |
176 for jid, session in pairs(user.sessions) do | |
177 session:close{ condition = "not-authorized", text = "Account deleted" }; | |
178 end | |
179 end | |
180 end, 200); | |
181 | |
172 --- Port listener | 182 --- Port listener |
173 function listener.onconnect(conn) | 183 function listener.onconnect(conn) |
174 local session = sm_new_session(conn); | 184 local session = sm_new_session(conn); |
175 sessions[conn] = session; | 185 sessions[conn] = session; |
176 | 186 |