From 612012dcb6f66e108bc82f9237597c21aeeb28b4 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 8 Mar 2009 03:46:44 +0500 Subject: usermanager: Added is_admin(jid) --- core/usermanager.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core/usermanager.lua') diff --git a/core/usermanager.lua b/core/usermanager.lua index fd8fe739..bee1502e 100644 --- a/core/usermanager.lua +++ b/core/usermanager.lua @@ -11,8 +11,12 @@ require "util.datamanager" local datamanager = datamanager; local log = require "util.logger".init("usermanager"); +local type = type; local error = error; +local ipairs = ipairs; local hashes = require "util.hashes"; +local jid_bare = require "util.jid".bare; +local config = require "core.configmanager"; module "usermanager" @@ -59,4 +63,15 @@ function get_supported_methods(host) return methods; end +function is_admin(jid) + local admins = config.get("*", "core", "admins") or {}; + 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 + return nil; +end + return _M; -- cgit v1.2.3