aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_register.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-01-04 17:19:39 +0000
committerMatthew Wild <mwild1@gmail.com>2011-01-04 17:19:39 +0000
commit55c8f50819e15b8a48194511c121420687a3942c (patch)
tree40d6bbab8fcf8278871c18216e735450308560e1 /plugins/mod_register.lua
parent07a2dfbb1ea35dbb6f4c857b8a84406e09dc2432 (diff)
downloadprosody-55c8f50819e15b8a48194511c121420687a3942c.tar.gz
prosody-55c8f50819e15b8a48194511c121420687a3942c.zip
mod_register: Change to use new delete_user auth provider method
Diffstat (limited to 'plugins/mod_register.lua')
-rw-r--r--plugins/mod_register.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua
index abbb7c94..7373adad 100644
--- a/plugins/mod_register.lua
+++ b/plugins/mod_register.lua
@@ -13,6 +13,7 @@ local datamanager = require "util.datamanager";
local usermanager_user_exists = require "core.usermanager".user_exists;
local usermanager_create_user = require "core.usermanager".create_user;
local usermanager_set_password = require "core.usermanager".set_password;
+local usermanager_delete_user = require "core.usermanager".delete_user;
local os_time = os.time;
local nodeprep = require "util.encodings".stringprep.nodeprep;
local jid_bare = require "util.jid".bare;
@@ -36,11 +37,15 @@ local function handle_registration_stanza(event)
if query.tags[1] and query.tags[1].name == "remove" then
-- TODO delete user auth data, send iq response, kick all user resources with a <not-authorized/>, delete all user data
local username, host = session.username, session.host;
- --session.send(st.error_reply(stanza, "cancel", "not-allowed"));
- --return;
- usermanager_set_password(username, nil, host); -- Disable account
- -- FIXME the disabling currently allows a different user to recreate the account
- -- we should add an in-memory account block mode when we have threading
+
+ 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.send(st.error_reply(stanza, "cancel", "service-unavailable", err));
+ return true;
+ end
+
session.send(st.reply(stanza));
local roster = session.roster;
for _, session in pairs(hosts[host].sessions[username].sessions) do -- disconnect all resources
@@ -63,7 +68,6 @@ local function handle_registration_stanza(event)
end
datamanager.store(username, host, "roster", nil);
datamanager.store(username, host, "privacy", nil);
- datamanager.store(username, host, "accounts", nil); -- delete accounts datastore at the end
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
@@ -180,4 +184,3 @@ module:hook("stanza/iq/jabber:iq:register:query", function(event)
end
return true;
end);
-