usermanager: Fix logic for per-host admin tables (thanks Maranda)

Wed, 12 May 2010 23:06:46 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 12 May 2010 23:06:46 +0100
changeset 3035
5584c928d1f7
parent 3034
b9ebd44a35f9
child 3036
0714539bcf71

usermanager: Fix logic for per-host admin tables (thanks Maranda)

core/usermanager.lua file | annotate | diff | comparison | revisions
--- a/core/usermanager.lua	Sun May 09 20:48:21 2010 +0100
+++ b/core/usermanager.lua	Wed May 12 23:06:46 2010 +0100
@@ -84,13 +84,15 @@
 
 	function provider.is_admin(jid)
 		local admins = config.get(host, "core", "admins");
-		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
+		if admins ~= config.get("*", "core", "admins") then
+			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("error", "Option 'admins' for host '%s' is not a table", host);
 			end
-		elseif admins then
-			log("error", "Option 'admins' for host '%s' is not a table", host);
 		end
 		return is_admin(jid); -- Test whether it's a global admin instead
 	end

mercurial