Software /
code /
prosody
Changeset
5098:fca8b5946f6f
mod_register: Hijack the session close call to send the final iq reply when deleting
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 25 Aug 2012 01:29:38 +0200 |
parents | 5097:6c52a7a881cc |
children | 5099:39eb688e106a |
files | plugins/mod_register.lua |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_register.lua Sat Aug 25 01:28:38 2012 +0200 +++ b/plugins/mod_register.lua Sat Aug 25 01:29:38 2012 +0200 @@ -96,16 +96,22 @@ else -- stanza.attr.type == "set" if query.tags[1] and query.tags[1].name == "remove" then local username, host = session.username, session.host; + + local old_session_close = session.close; + session.close = function(session, ...) + session.send(st.reply(stanza)); + return old_session_close(session, ...); + end local ok, err = usermanager_delete_user(username, host); if not ok then module:log("debug", "Removing user account %s@%s failed: %s", username, host, err); + session.close = old_session_close; session.send(st.error_reply(stanza, "cancel", "service-unavailable", err)); return true; end - session.send(st.reply(stanza)); module:log("info", "User removed their account: %s@%s", username, host); module:fire_event("user-deregistered", { username = username, host = host, source = "mod_register", session = session }); else