X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=core%2Fusermanager.lua;h=925ac774071489eedae3dfae20bd3547d23f9452;hb=23c6f9b64369d6ac527c8e03bea3ad81d31fbe80;hp=955218cc61af2915e343c9d0a6c98f63df5ff7b0;hpb=165058715b1a5cd98be79a5d1d007b444be03a9a;p=prosody.git diff --git a/core/usermanager.lua b/core/usermanager.lua index 955218cc..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; @@ -63,19 +60,21 @@ function create_user(username, password, host) end function get_supported_methods(host) - local methods = {["PLAIN"] = true}; -- TODO this should be taken from the config - methods["DIGEST-MD5"] = true; - return methods; + 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 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