Software /
code /
prosody
Comparison
core/usermanager.lua @ 2034:38d4694828e6
Merged with trunk.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 21 Oct 2009 12:02:30 +0500 |
parent | 2032:2714ccde2569 |
child | 2923:b7049746bd29 |
comparison
equal
deleted
inserted
replaced
2027:4cd673721e72 | 2034:38d4694828e6 |
---|---|
4 -- | 4 -- |
5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 | 9 local datamanager = require "util.datamanager"; |
10 | |
11 require "util.datamanager" | |
12 local datamanager = datamanager; | |
13 local log = require "util.logger".init("usermanager"); | 10 local log = require "util.logger".init("usermanager"); |
14 local type = type; | 11 local type = type; |
15 local error = error; | 12 local error = error; |
16 local ipairs = ipairs; | 13 local ipairs = ipairs; |
17 local hashes = require "util.hashes"; | 14 local hashes = require "util.hashes"; |
64 | 61 |
65 function get_supported_methods(host) | 62 function get_supported_methods(host) |
66 return {["PLAIN"] = true, ["DIGEST-MD5"] = true}; -- TODO this should be taken from the config | 63 return {["PLAIN"] = true, ["DIGEST-MD5"] = true}; -- TODO this should be taken from the config |
67 end | 64 end |
68 | 65 |
69 function is_admin(jid) | 66 function is_admin(jid, host) |
70 local admins = config.get("*", "core", "admins"); | 67 host = host or "*"; |
68 local admins = config.get(host, "core", "admins"); | |
69 if host ~= "*" and admins == config.get("*", "core", "admins") then | |
70 return nil; | |
71 end | |
71 if type(admins) == "table" then | 72 if type(admins) == "table" then |
72 jid = jid_bare(jid); | 73 jid = jid_bare(jid); |
73 for _,admin in ipairs(admins) do | 74 for _,admin in ipairs(admins) do |
74 if admin == jid then return true; end | 75 if admin == jid then return true; end |
75 end | 76 end |
76 else log("debug", "Option core.admins is not a table"); end | 77 elseif admins then log("warn", "Option 'admins' for host '%s' is not a table", host); end |
77 return nil; | 78 return nil; |
78 end | 79 end |
79 | 80 |
80 return _M; | 81 return _M; |