Software /
code /
prosody
Changeset
890:5b8da51b0843
usermanager: Added is_admin(jid)
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 08 Mar 2009 03:46:44 +0500 |
parents | 889:bb959588bbc4 |
children | 891:236d1ce9fa99 |
files | core/usermanager.lua |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
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;