aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/usermanager.lua37
1 files changed, 28 insertions, 9 deletions
diff --git a/core/usermanager.lua b/core/usermanager.lua
index bb8cd962..a369b9e0 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -91,24 +91,43 @@ end
function is_admin(jid, host)
local is_admin;
- if host and host ~= "*" then
- is_admin = hosts[host].users.is_admin(jid);
+ jid = jid_bare(jid);
+ host = host or "*";
+
+ local host_admins = config.get(host, "core", "admins");
+ local global_admins = config.get("*", "core", "admins");
+
+ if host_admins and host_admins ~= global_admins then
+ if type(host_admins) == "table" then
+ for _,admin in ipairs(host_admins) do
+ if admin == jid then
+ is_admin = true;
+ break;
+ end
+ end
+ elseif admins then
+ log("error", "Option 'admins' for host '%s' is not a list", host);
+ end
end
- if not is_admin then -- Test only whether this JID is a global admin
- local admins = config.get("*", "core", "admins");
- if type(admins) == "table" then
- jid = jid_bare(jid);
- for _,admin in ipairs(admins) do
+
+ if not is_admin and global_admins then
+ if type(global_admins) == "table" then
+ for _,admin in ipairs(global_admins) do
if admin == jid then
is_admin = true;
break;
end
end
elseif admins then
- log("error", "Option 'admins' for host '%s' is not a table", host);
+ log("error", "Global option 'admins' is not a list");
end
end
- return is_admin;
+
+ -- Still not an admin, check with auth provider
+ if not is_admin and host ~= "*" and hosts[host].users.is_admin then
+ is_admin = hosts[host].users.is_admin(jid);
+ end
+ return is_admin or false;
end
return _M;