Software /
code /
prosody
Diff
core/usermanager.lua @ 890:5b8da51b0843
usermanager: Added is_admin(jid)
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 08 Mar 2009 03:46:44 +0500 |
parent | 760:90ce865eebd8 |
child | 896:2c0b9e3c11c3 |
line wrap: on
line diff
--- a/core/usermanager.lua Sun Mar 08 01:07:29 2009 +0500 +++ b/core/usermanager.lua Sun Mar 08 03:46:44 2009 +0500 @@ -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 @@ 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;