aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/storagemanager.lua12
-rw-r--r--core/usermanager.lua12
2 files changed, 22 insertions, 2 deletions
diff --git a/core/storagemanager.lua b/core/storagemanager.lua
index 71e79271..3379cc0c 100644
--- a/core/storagemanager.lua
+++ b/core/storagemanager.lua
@@ -58,7 +58,7 @@ function load_driver(host, driver_name)
return stores_available:get(host, driver_name);
end
-function open(host, store, typ)
+function get_driver(host, store)
local storage = config.get(host, "core", "storage");
local driver_name;
local option_type = type(storage);
@@ -77,7 +77,11 @@ function open(host, store, typ)
driver_name = "null";
driver = null_storage_driver;
end
+ return driver, driver_name;
+ end
+function open(host, store, typ)
+ local driver, driver_name = get_driver(host, store);
local ret, err = driver:open(store, typ);
if not ret then
if err == "unsupported-store" then
@@ -96,5 +100,11 @@ end
function datamanager.store(username, host, datastore, data)
return open(host, datastore):set(username, data);
end
+function datamanager.list_stores(username, host)
+ return get_driver(host):list_stores(username, host);
+end
+function datamanager.purge(username, host)
+ return get_driver(host):purge(username, host);
+end
return _M;
diff --git a/core/usermanager.lua b/core/usermanager.lua
index 3aba5786..efc15b7c 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -10,11 +10,13 @@ local modulemanager = require "core.modulemanager";
local log = require "util.logger".init("usermanager");
local type = type;
local ipairs = ipairs;
+local pairs = pairs;
local jid_bare = require "util.jid".bare;
local jid_prep = require "util.jid".prep;
local config = require "core.configmanager";
local hosts = hosts;
local sasl_new = require "util.sasl".new;
+local storagemanager = require "core.storagemanager";
local prosody = _G.prosody;
@@ -88,7 +90,15 @@ function create_user(username, password, host)
end
function delete_user(username, host)
- return hosts[host].users.delete_user(username);
+ local user = hosts[host].sessions[username];
+ if user and user.sessions then
+ for jid, session in pairs(user.sessions) do
+ session:close{ condition = "not-authorized", text = "Account deleted" };
+ end
+ end
+ local ok, err = hosts[host].users.delete_user(username);
+ if not ok then return nil, err; end
+ return storagemanager.get_driver(host):purge(username);
end
function get_sasl_handler(host, session)