From a8d9cebe3c1a14d8a4b280272aa7b37e6906a214 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 25 Aug 2012 01:29:38 +0200 Subject: mod_register: Hijack the session close call to send the final iq reply when deleting --- plugins/mod_register.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua index a621b9a9..dfc8c49b 100644 --- a/plugins/mod_register.lua +++ b/plugins/mod_register.lua @@ -96,16 +96,22 @@ local function handle_registration_stanza(event) 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 -- cgit v1.2.3