From 057cf59598c1fa755fbbb7a0c9e55b40fc00ce78 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Wed, 21 Oct 2009 11:39:02 +0500 Subject: usermanager: Changed function is_admin to allow checking for host-specific admins. --- core/usermanager.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core/usermanager.lua') diff --git a/core/usermanager.lua b/core/usermanager.lua index 6c36fa29..04154cdb 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -66,8 +66,12 @@ function get_supported_methods(host) return {["PLAIN"] = true, ["DIGEST-MD5"] = true}; -- TODO this should be taken from the config end -function is_admin(jid) - local admins = config.get("*", "core", "admins"); +function is_admin(jid, host) + 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 jid = jid_bare(jid); for _,admin in ipairs(admins) do -- cgit v1.2.3 From f3997f036d09e62d33e058d12eea4e0586ce4e15 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Wed, 21 Oct 2009 11:40:29 +0500 Subject: usermanager: Logged a clear warning when the 'admins' option is not a table. --- core/usermanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/usermanager.lua') diff --git a/core/usermanager.lua b/core/usermanager.lua index 04154cdb..acc482e3 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -77,7 +77,7 @@ function is_admin(jid, host) for _,admin in ipairs(admins) do if admin == jid then return true; end end - else log("debug", "Option core.admins is not a table"); end + elseif admins then log("warn", "Option 'admins' for host '%s' is not a table", host); end return nil; end -- cgit v1.2.3 From 43b59ec6d3cfcfb536e9ea8b6801d7b814ab1cc6 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Wed, 21 Oct 2009 11:41:11 +0500 Subject: usermanager: Removed an unnecessary global access. --- core/usermanager.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'core/usermanager.lua') diff --git a/core/usermanager.lua b/core/usermanager.lua index acc482e3..925ac774 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -6,10 +6,7 @@ -- COPYING file in the source package for more information. -- - - -require "util.datamanager" -local datamanager = datamanager; +local datamanager = require "util.datamanager"; local log = require "util.logger".init("usermanager"); local type = type; local error = error; -- cgit v1.2.3