aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-02-23 16:24:41 +0100
committerKim Alvefur <zash@zash.se>2023-02-23 16:24:41 +0100
commit931c14e50b186f65c2f57309147dda54d12bb02a (patch)
treee13171ae7fc1acff25669e37541b8d1a3efdc4f6 /core
parentef6ad34029730e300975d9e2b86d6aa8d8043b24 (diff)
downloadprosody-931c14e50b186f65c2f57309147dda54d12bb02a.tar.gz
prosody-931c14e50b186f65c2f57309147dda54d12bb02a.zip
core.usermanager: Add methods for enabling and disabling users
Calling into the auth module, where available.
Diffstat (limited to 'core')
-rw-r--r--core/usermanager.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/usermanager.lua b/core/usermanager.lua
index fcb1fa9b..439d4a8b 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -135,6 +135,35 @@ local function delete_user(username, host)
return storagemanager.purge(username, host);
end
+local function user_is_enabled(username, host)
+ local method = hosts[host].users.is_enabled;
+ if method then return method(username); end
+
+ -- Fallback
+ local info, err = get_account_info(username, host);
+ if info and info.enabled ~= nil then
+ return info.enabled;
+ elseif err ~= "method-not-implemented" then
+ -- Storage issues etetc
+ return info, err;
+ end
+
+ -- API unsupported implies users are always enabled
+ return true;
+end
+
+local function enable_user(username, host)
+ local method = hosts[host].users.enable;
+ if not method then return nil, "method-not-supported"; end
+ return method(username);
+end
+
+local function disable_user(username, host)
+ local method = hosts[host].users.disable;
+ if not method then return nil, "method-not-supported"; end
+ return method(username);
+end
+
local function users(host)
return hosts[host].users.users();
end
@@ -266,6 +295,9 @@ return {
user_exists = user_exists;
create_user = create_user;
delete_user = delete_user;
+ user_is_enabled = user_is_enabled;
+ enable_user = enable_user;
+ disable_user = disable_user;
users = users;
get_sasl_handler = get_sasl_handler;
get_provider = get_provider;