Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 12019:a0b6896bb538
mod_admin_shell: Handle global roles (pass host=*)
Is it not odd that um.set_roles() takes `nil` to mean global?
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 06 Dec 2021 22:33:46 +0100 |
parent | 12018:c65789f5004e |
child | 12023:5a3781a12285 |
comparison
equal
deleted
inserted
replaced
12018:c65789f5004e | 12019:a0b6896bb538 |
---|---|
1331 -- user:roles("someone@example.com", "example.com", {"prosody:admin"}) | 1331 -- user:roles("someone@example.com", "example.com", {"prosody:admin"}) |
1332 -- user:roles("someone@example.com", {"prosody:admin"}) | 1332 -- user:roles("someone@example.com", {"prosody:admin"}) |
1333 function def_env.user:roles(jid, host, new_roles) | 1333 function def_env.user:roles(jid, host, new_roles) |
1334 local username, userhost = jid_split(jid); | 1334 local username, userhost = jid_split(jid); |
1335 if new_roles == nil then host, new_roles = userhost, host; end | 1335 if new_roles == nil then host, new_roles = userhost, host; end |
1336 if not prosody.hosts[host] then | 1336 if host ~= "*" and not prosody.hosts[host] then |
1337 return nil, "No such host: "..host; | 1337 return nil, "No such host: "..host; |
1338 elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then | 1338 elseif prosody.hosts[userhost] and not um.user_exists(username, userhost) then |
1339 return nil, "No such user"; | 1339 return nil, "No such user"; |
1340 end | 1340 end |
1341 if host == "*" then host = nil; end | |
1341 return um.set_roles(jid, host, coerce_roles(new_roles)); | 1342 return um.set_roles(jid, host, coerce_roles(new_roles)); |
1342 end | 1343 end |
1343 | 1344 |
1344 -- TODO switch to table view, include roles | 1345 -- TODO switch to table view, include roles |
1345 function def_env.user:list(host, pat) | 1346 function def_env.user:list(host, pat) |