mirror of
https://github.com/bjc/prosody.git
synced 2025-04-06 22:57:38 +03:00
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:
parent
458f098b1c
commit
15b310c4e2
2 changed files with 48 additions and 30 deletions
16
plugins/mod_authz_internal.lua
Normal file
16
plugins/mod_authz_internal.lua
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue