aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-06 21:56:19 +0100
committerKim Alvefur <zash@zash.se>2021-12-06 21:56:19 +0100
commitcf137f99020a2f1ac67b761861a7baa4ef2cfe07 (patch)
tree6380eacf960127de3fa2d8c24fa4df651301e416 /plugins
parentefa1f442ae1cce4bfd537ab3a9ab27acd05a6573 (diff)
downloadprosody-cf137f99020a2f1ac67b761861a7baa4ef2cfe07.tar.gz
prosody-cf137f99020a2f1ac67b761861a7baa4ef2cfe07.zip
mod_admin_shell: Support setting roles on hosts other than the users'
Needed to e.g. grant admin rights on a component, or grant non-local users local privileges. Leave the same host syntax for convenience, since this might be the common case.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_admin_shell.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index 5e021173..b7800764 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -250,7 +250,7 @@ function commands.help(session, data)
elseif section == "user" then
print [[user:create(jid, password, roles) - Create the specified user account]]
print [[user:password(jid, password) - Set the password for the specified user account]]
- print [[user:roles(jid, roles) - Set roles for an user]]
+ print [[user:roles(jid, host, roles) - Set roles for an user (see 'help roles')]]
print [[user:delete(jid) - Permanently remove the specified user account]]
print [[user:list(hostname, pattern) - List users on the specified host, optionally filtering with a pattern]]
elseif section == "muc" then
@@ -1328,12 +1328,16 @@ function def_env.user:password(jid, password)
end
end
+-- user:roles("someone@example.com", "example.com", {"prosody:admin"})
-- user:roles("someone@example.com", {"prosody:admin"})
-function def_env.user:roles(jid, new_roles)
- local username, host = jid_split(jid);
+function def_env.user:roles(jid, host, new_roles)
+ local username, userhost = jid_split(jid);
+ if new_roles == nil then host, new_roles = userhost, host; end
if not prosody.hosts[host] then
return nil, "No such host: "..host;
- elseif not um.user_exists(username, host) then
+ elseif not prosody.hosts[userhost] then
+ return nil, "No such host: "..userhost;
+ elseif not um.user_exists(username, userhost) then
return nil, "No such user";
end
return um.set_roles(jid, host, coerce_roles(new_roles));