Comparison

plugins/mod_admin_shell.lua @ 12638:a47af78a9347

Merge 0.12->trunk
author Matthew Wild <mwild1@gmail.com>
date Thu, 18 Aug 2022 15:43:16 +0100
parent 12603:05ca75309fa0
parent 12637:2200f0c6b3f1
child 12660:e8f57970ced5
comparison
equal deleted inserted replaced
12636:e8934ce6ea0f 12638:a47af78a9347
268 print [[host:deactivate(hostname) - Disconnects all clients on this host and deactivates]] 268 print [[host:deactivate(hostname) - Disconnects all clients on this host and deactivates]]
269 print [[host:list() - List the currently-activated hosts]] 269 print [[host:list() - List the currently-activated hosts]]
270 elseif section == "user" then 270 elseif section == "user" then
271 print [[user:create(jid, password, roles) - Create the specified user account]] 271 print [[user:create(jid, password, roles) - Create the specified user account]]
272 print [[user:password(jid, password) - Set the password for the specified user account]] 272 print [[user:password(jid, password) - Set the password for the specified user account]]
273 print [[user:showroles(jid, host) - Show current roles for an user]] 273 print [[user:roles(jid, host) - Show current roles for an user]]
274 print [[user:roles(jid, host, roles) - Set roles for an user (see 'help roles')]] 274 print [[user:setroles(jid, host, roles) - Set roles for an user (see 'help roles')]]
275 print [[user:delete(jid) - Permanently remove the specified user account]] 275 print [[user:delete(jid) - Permanently remove the specified user account]]
276 print [[user:list(hostname, pattern) - List users on the specified host, optionally filtering with a pattern]] 276 print [[user:list(hostname, pattern) - List users on the specified host, optionally filtering with a pattern]]
277 elseif section == "roles" then 277 elseif section == "roles" then
278 print [[Roles may grant access or restrict users from certain operations]] 278 print [[Roles may grant access or restrict users from certain operations]]
279 print [[Built-in roles are:]] 279 print [[Built-in roles are:]]
1430 else 1430 else
1431 return nil, "Could not change password for user: "..err; 1431 return nil, "Could not change password for user: "..err;
1432 end 1432 end
1433 end 1433 end
1434 1434
1435 function def_env.user:showroles(jid, host) 1435 function def_env.user:roles(jid, host, new_roles)
1436 if new_roles or type(host) == "table" then
1437 return nil, "Use user:setroles(jid, host, roles) to change user roles";
1438 end
1436 local username, userhost = jid_split(jid); 1439 local username, userhost = jid_split(jid);
1437 if host == nil then host = userhost; end 1440 if host == nil then host = userhost; end
1438 if host ~= "*" and not prosody.hosts[host] then 1441 if host ~= "*" and not prosody.hosts[host] then
1439 return nil, "No such host: "..host; 1442 return nil, "No such host: "..host;
1440 elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then 1443 elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then
1448 count = count + 1; 1451 count = count + 1;
1449 print(role); 1452 print(role);
1450 end 1453 end
1451 return true, count == 1 and "1 role" or count.." roles"; 1454 return true, count == 1 and "1 role" or count.." roles";
1452 end 1455 end
1456 def_env.user.showroles = def_env.user.roles; -- COMPAT
1453 1457
1454 -- user:roles("someone@example.com", "example.com", {"prosody:admin"}) 1458 -- user:roles("someone@example.com", "example.com", {"prosody:admin"})
1455 -- user:roles("someone@example.com", {"prosody:admin"}) 1459 -- user:roles("someone@example.com", {"prosody:admin"})
1456 function def_env.user:roles(jid, host, new_roles) 1460 function def_env.user:setroles(jid, host, new_roles)
1457 local username, userhost = jid_split(jid); 1461 local username, userhost = jid_split(jid);
1458 if new_roles == nil then host, new_roles = userhost, host; end 1462 if new_roles == nil then host, new_roles = userhost, host; end
1459 if host ~= "*" and not prosody.hosts[host] then 1463 if host ~= "*" and not prosody.hosts[host] then
1460 return nil, "No such host: "..host; 1464 return nil, "No such host: "..host;
1461 elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then 1465 elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then