Software /
code /
prosody
Comparison
core/usermanager.lua @ 5776:bd0ff8ae98a8
Remove all trailing whitespace
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 09 Aug 2013 17:48:21 +0200 |
parent | 5377:898454038524 |
child | 5795:47c2f71d8314 |
comparison
equal
deleted
inserted
replaced
5775:a6c2b8933507 | 5776:bd0ff8ae98a8 |
---|---|
37 local provider_mt = { __index = new_null_provider() }; | 37 local provider_mt = { __index = new_null_provider() }; |
38 | 38 |
39 function initialize_host(host) | 39 function initialize_host(host) |
40 local host_session = hosts[host]; | 40 local host_session = hosts[host]; |
41 if host_session.type ~= "local" then return; end | 41 if host_session.type ~= "local" then return; end |
42 | 42 |
43 host_session.events.add_handler("item-added/auth-provider", function (event) | 43 host_session.events.add_handler("item-added/auth-provider", function (event) |
44 local provider = event.item; | 44 local provider = event.item; |
45 local auth_provider = config.get(host, "authentication") or default_provider; | 45 local auth_provider = config.get(host, "authentication") or default_provider; |
46 if config.get(host, "anonymous_login") then | 46 if config.get(host, "anonymous_login") then |
47 log("error", "Deprecated config option 'anonymous_login'. Use authentication = 'anonymous' instead."); | 47 log("error", "Deprecated config option 'anonymous_login'. Use authentication = 'anonymous' instead."); |
113 if type(jid) ~= "string" then return false; end | 113 if type(jid) ~= "string" then return false; end |
114 | 114 |
115 local is_admin; | 115 local is_admin; |
116 jid = jid_bare(jid); | 116 jid = jid_bare(jid); |
117 host = host or "*"; | 117 host = host or "*"; |
118 | 118 |
119 local host_admins = config.get(host, "admins"); | 119 local host_admins = config.get(host, "admins"); |
120 local global_admins = config.get("*", "admins"); | 120 local global_admins = config.get("*", "admins"); |
121 | 121 |
122 if host_admins and host_admins ~= global_admins then | 122 if host_admins and host_admins ~= global_admins then |
123 if type(host_admins) == "table" then | 123 if type(host_admins) == "table" then |
124 for _,admin in ipairs(host_admins) do | 124 for _,admin in ipairs(host_admins) do |
125 if jid_prep(admin) == jid then | 125 if jid_prep(admin) == jid then |
126 is_admin = true; | 126 is_admin = true; |
129 end | 129 end |
130 elseif host_admins then | 130 elseif host_admins then |
131 log("error", "Option 'admins' for host '%s' is not a list", host); | 131 log("error", "Option 'admins' for host '%s' is not a list", host); |
132 end | 132 end |
133 end | 133 end |
134 | 134 |
135 if not is_admin and global_admins then | 135 if not is_admin and global_admins then |
136 if type(global_admins) == "table" then | 136 if type(global_admins) == "table" then |
137 for _,admin in ipairs(global_admins) do | 137 for _,admin in ipairs(global_admins) do |
138 if jid_prep(admin) == jid then | 138 if jid_prep(admin) == jid then |
139 is_admin = true; | 139 is_admin = true; |
142 end | 142 end |
143 elseif global_admins then | 143 elseif global_admins then |
144 log("error", "Global option 'admins' is not a list"); | 144 log("error", "Global option 'admins' is not a list"); |
145 end | 145 end |
146 end | 146 end |
147 | 147 |
148 -- Still not an admin, check with auth provider | 148 -- Still not an admin, check with auth provider |
149 if not is_admin and host ~= "*" and hosts[host].users and hosts[host].users.is_admin then | 149 if not is_admin and host ~= "*" and hosts[host].users and hosts[host].users.is_admin then |
150 is_admin = hosts[host].users.is_admin(jid); | 150 is_admin = hosts[host].users.is_admin(jid); |
151 end | 151 end |
152 return is_admin or false; | 152 return is_admin or false; |