aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-06-22 19:00:01 +0100
committerMatthew Wild <mwild1@gmail.com>2010-06-22 19:00:01 +0100
commit434a0e7b67941da4adf2c38b94bd5ec23bc0892b (patch)
tree62abe8f189115e364f30ce690ffe077deb26bfe2
parent1f75bd5099dde7e46660b90deff5b09553ee1e7e (diff)
downloadprosody-434a0e7b67941da4adf2c38b94bd5ec23bc0892b.tar.gz
prosody-434a0e7b67941da4adf2c38b94bd5ec23bc0892b.zip
usermanager: is_admin: Resume the old role of determining precisely whether a user is an admin for a given host (or a global admin) - auth providers checked for JIDs not listed in the config if they support it
-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;