aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-08-15 18:56:22 +0200
committerKim Alvefur <zash@zash.se>2022-08-15 18:56:22 +0200
commitee21d9480a7b168cc7971f4ef3d3879b3b045bd1 (patch)
tree6478473af28b7cbd1158f284b9815b1f7f73f99d /plugins
parent2dbbce23823edbf4261df92175d7ee9cf7cca3a9 (diff)
downloadprosody-ee21d9480a7b168cc7971f4ef3d3879b3b045bd1.tar.gz
prosody-ee21d9480a7b168cc7971f4ef3d3879b3b045bd1.zip
mod_admin_shell: Switch names for user role management commands
user:roles() does not convey that this is the mutating command, it should have been called setroles from the start but wasn't due to lack of foresight. This has to accidentally removing roles when wanting to show them.
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 94530cf1..f8fa7242 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -257,8 +257,8 @@ 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:showroles(jid, host) - Show current roles for an user]]
- print [[user:roles(jid, host, roles) - Set roles for an user (see 'help roles')]]
+ print [[user:roles(jid, host) - Show current roles for an user]]
+ print [[user:setroles(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 == "roles" then
@@ -1399,7 +1399,10 @@ function def_env.user:password(jid, password)
end
end
-function def_env.user:showroles(jid, host)
+function def_env.user:roles(jid, host, new_roles)
+ if new_roles or type(host) == "table" then
+ return nil, "Use user:setroles(jid, host, roles) to change user roles";
+ end
local username, userhost = jid_split(jid);
if host == nil then host = userhost; end
if host ~= "*" and not prosody.hosts[host] then
@@ -1417,10 +1420,11 @@ function def_env.user:showroles(jid, host)
end
return true, count == 1 and "1 role" or count.." roles";
end
+def_env.user.showroles = def_env.user.roles; -- COMPAT
-- user:roles("someone@example.com", "example.com", {"prosody:admin"})
-- user:roles("someone@example.com", {"prosody:admin"})
-function def_env.user:roles(jid, host, new_roles)
+function def_env.user:setroles(jid, host, new_roles)
local username, userhost = jid_split(jid);
if new_roles == nil then host, new_roles = userhost, host; end
if host ~= "*" and not prosody.hosts[host] then