Mercurial > prosody-modules
comparison mod_muc_http_auth/mod_muc_http_auth.lua @ 4301:bcb2b9adfcde
mod_muc_http_auth: Use get_option_set API properly
author | Seve Ferrer <seve@delape.net> |
---|---|
date | Tue, 15 Dec 2020 14:16:11 +0100 |
parents | 8006da2cf44c |
children | d261233f7ced |
comparison
equal
deleted
inserted
replaced
4300:3f3b672b7616 | 4301:bcb2b9adfcde |
---|---|
10 local disabled_for = module:get_option_set("muc_http_auth_disabled_for", nil) | 10 local disabled_for = module:get_option_set("muc_http_auth_disabled_for", nil) |
11 local insecure = module:get_option("muc_http_auth_insecure", false) --For development purposes | 11 local insecure = module:get_option("muc_http_auth_insecure", false) --For development purposes |
12 local authorize_registration = module:get_option("muc_http_auth_authorize_registration", false) | 12 local authorize_registration = module:get_option("muc_http_auth_authorize_registration", false) |
13 | 13 |
14 local function must_be_authorized(room_node) | 14 local function must_be_authorized(room_node) |
15 -- If none of these is set, all rooms need authorization | 15 -- If none or both of these are set, all rooms need authorization |
16 if not enabled_for and not disabled_for then return true; end | 16 if not enabled_for and not disabled_for then return true; end |
17 if enabled_for and disabled_for then return true; end | |
17 | 18 |
18 if enabled_for and not disabled_for then | 19 if enabled_for then return enabled_for:contains(room_node); end |
19 for _, _room_node in ipairs(enabled_for) do | 20 if disabled_for then return not disabled_for:contains(room_node); end |
20 if _room_node == room_node then | |
21 return true; | |
22 end | |
23 end | |
24 end | |
25 | |
26 if disabled_for and not enabled_for then | |
27 for _, _room_node in ipairs(disabled_for) do | |
28 if _room_node == room_node then | |
29 return false; | |
30 end | |
31 end | |
32 end | |
33 | |
34 return true; | |
35 end | 21 end |
36 | 22 |
37 local function handle_success(response) | 23 local function handle_success(response) |
38 local body = json.decode(response.body or "") or {} | 24 local body = json.decode(response.body or "") or {} |
39 response = { | 25 response = { |