usermanager: Handle checking for global admins on behalf of providers

Wed, 09 Jun 2010 21:24:20 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 09 Jun 2010 21:24:20 +0100
changeset 3218
032b81731f0f
parent 3217
382f70627ff9
child 3219
fd06023cbdcc

usermanager: Handle checking for global admins on behalf of providers

core/usermanager.lua file | annotate | diff | comparison | revisions
--- a/core/usermanager.lua	Wed Jun 09 22:20:53 2010 +0500
+++ b/core/usermanager.lua	Wed Jun 09 21:24:20 2010 +0100
@@ -90,20 +90,25 @@
 end
 
 function is_admin(jid, host)
+	local is_admin;
 	if host and host ~= "*" then
-		return hosts[host].users.is_admin(jid);
-	else -- Test only whether this JID is a global admin
+		is_admin = hosts[host].users.is_admin(jid);
+	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 admin == jid then return true; end
+				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);
 		end
-		return nil;
 	end
+	return is_admin;
 end
 
 return _M;

mercurial