usermanager, mod_authz_internal: Move admin-checking functionality into a module. Fixes #517 (ish).

Note: Removes the ability for mod_auth_* providers to determine user admin status. Such
modules will need to have their is_admin methods ported to be a mod_authz_* provider.
This commit is contained in:
Matthew Wild 2020-01-27 21:54:59 +00:00
parent 458f098b1c
commit 15b310c4e2
2 changed files with 48 additions and 30 deletions

View file

@ -0,0 +1,16 @@
local normalize = require "util.jid".prep;
local admin_jids = module:get_option_inherited_set("admins", {}) / normalize;
local host = module.host;
local admin_role = { ["prosody:admin"] = true };
function get_user_roles(user)
return get_jid_roles(user.."@"..host);
end
function get_jid_roles(jid)
if admin_jids:contains(jid) then
return admin_role;
end
return nil;
end