Comparison

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
comparison
equal deleted inserted replaced
889:bb959588bbc4 890:5b8da51b0843
9 9
10 10
11 require "util.datamanager" 11 require "util.datamanager"
12 local datamanager = datamanager; 12 local datamanager = datamanager;
13 local log = require "util.logger".init("usermanager"); 13 local log = require "util.logger".init("usermanager");
14 local type = type;
14 local error = error; 15 local error = error;
16 local ipairs = ipairs;
15 local hashes = require "util.hashes"; 17 local hashes = require "util.hashes";
18 local jid_bare = require "util.jid".bare;
19 local config = require "core.configmanager";
16 20
17 module "usermanager" 21 module "usermanager"
18 22
19 function validate_credentials(host, username, password, method) 23 function validate_credentials(host, username, password, method)
20 log("debug", "User '%s' is being validated", username); 24 log("debug", "User '%s' is being validated", username);
57 local methods = {["PLAIN"] = true}; -- TODO this should be taken from the config 61 local methods = {["PLAIN"] = true}; -- TODO this should be taken from the config
58 methods["DIGEST-MD5"] = true; 62 methods["DIGEST-MD5"] = true;
59 return methods; 63 return methods;
60 end 64 end
61 65
66 function is_admin(jid)
67 local admins = config.get("*", "core", "admins") or {};
68 if type(admins) == "table" then
69 jid = jid_bare(jid);
70 for _,admin in ipairs(admins) do
71 if admin == jid then return true; end
72 end
73 else log("debug", "Option core.admins is not a table"); end
74 return nil;
75 end
76
62 return _M; 77 return _M;