Software /
code /
prosody
Comparison
core/usermanager.lua @ 3218:032b81731f0f
usermanager: Handle checking for global admins on behalf of providers
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 09 Jun 2010 21:24:20 +0100 |
parent | 3185:09174a6e8366 |
child | 3285:c116c4b2db5a |
comparison
equal
deleted
inserted
replaced
3217:382f70627ff9 | 3218:032b81731f0f |
---|---|
88 function get_provider(host) | 88 function get_provider(host) |
89 return hosts[host].users; | 89 return hosts[host].users; |
90 end | 90 end |
91 | 91 |
92 function is_admin(jid, host) | 92 function is_admin(jid, host) |
93 local is_admin; | |
93 if host and host ~= "*" then | 94 if host and host ~= "*" then |
94 return hosts[host].users.is_admin(jid); | 95 is_admin = hosts[host].users.is_admin(jid); |
95 else -- Test only whether this JID is a global admin | 96 end |
97 if not is_admin then -- Test only whether this JID is a global admin | |
96 local admins = config.get("*", "core", "admins"); | 98 local admins = config.get("*", "core", "admins"); |
97 if type(admins) == "table" then | 99 if type(admins) == "table" then |
98 jid = jid_bare(jid); | 100 jid = jid_bare(jid); |
99 for _,admin in ipairs(admins) do | 101 for _,admin in ipairs(admins) do |
100 if admin == jid then return true; end | 102 if admin == jid then |
103 is_admin = true; | |
104 break; | |
105 end | |
101 end | 106 end |
102 elseif admins then | 107 elseif admins then |
103 log("error", "Option 'admins' for host '%s' is not a table", host); | 108 log("error", "Option 'admins' for host '%s' is not a table", host); |
104 end | 109 end |
105 return nil; | |
106 end | 110 end |
111 return is_admin; | |
107 end | 112 end |
108 | 113 |
109 return _M; | 114 return _M; |