aboutsummaryrefslogtreecommitdiffstats
path: root/core/usermanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-05-07 21:42:45 +0100
committerMatthew Wild <mwild1@gmail.com>2010-05-07 21:42:45 +0100
commita638f49976e894a83b15912bb17e2d3921a0651f (patch)
tree4e89010c2125ab92317a355ae13bc348aeee1ea4 /core/usermanager.lua
parent896c6443c55ba89cc4a22063ab91c8f105a96149 (diff)
downloadprosody-a638f49976e894a83b15912bb17e2d3921a0651f.tar.gz
prosody-a638f49976e894a83b15912bb17e2d3921a0651f.zip
usermanager: Fix for is_admin to work with the new auth provider architecture
Diffstat (limited to 'core/usermanager.lua')
-rw-r--r--core/usermanager.lua23
1 files changed, 16 insertions, 7 deletions
diff --git a/core/usermanager.lua b/core/usermanager.lua
index 1ee4736e..c9ac041c 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -83,12 +83,8 @@ function new_default_provider(host)
end
function provider.is_admin(jid)
- host = host or "*";
local admins = config.get(host, "core", "admins");
- if host ~= "*" and admins == config.get("*", "core", "admins") then
- return nil;
- end
- if type(admins) == "table" then
+ if admins ~= config.get("*", "core", "admins") and type(admins) == "table" then
jid = jid_bare(jid);
for _,admin in ipairs(admins) do
if admin == jid then return true; end
@@ -96,7 +92,7 @@ function new_default_provider(host)
elseif admins then
log("warn", "Option 'admins' for host '%s' is not a table", host);
end
- return nil;
+ return is_admin(jid); -- Test whether it's a global admin instead
end
return provider;
end
@@ -126,7 +122,20 @@ function get_supported_methods(host)
end
function is_admin(jid, host)
- return hosts[host].users.is_admin(jid);
+ if host and host ~= "*" then
+ return hosts[host].users.is_admin(jid);
+ else -- 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 admin == jid then return true; end
+ end
+ elseif admins then
+ log("warn", "Option 'admins' for host '%s' is not a table", host);
+ end
+ return nil;
+ end
end
return _M;