comparison mod_http_admin_api/mod_http_admin_api.lua @ 4352:f6da234b21b8

mod_http_admin_api: Add groups property to users
author Matthew Wild <mwild1@gmail.com>
date Sun, 17 Jan 2021 17:51:23 +0000
parents c0b1b2a61e3c
children 535d80be110d
comparison
equal deleted inserted replaced
4351:c0b1b2a61e3c 4352:f6da234b21b8
5 module:depends("http"); 5 module:depends("http");
6 6
7 local invites = module:depends("invites"); 7 local invites = module:depends("invites");
8 local tokens = module:depends("tokenauth"); 8 local tokens = module:depends("tokenauth");
9 local mod_pep = module:depends("pep"); 9 local mod_pep = module:depends("pep");
10
11 local group_memberships = module:open_store("groups", "map");
10 12
11 local json_content_type = "application/json"; 13 local json_content_type = "application/json";
12 14
13 local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name); 15 local www_authenticate_header = ("Bearer realm=%q"):format(module.host.."/"..module.name);
14 16
147 if ok and nick_item then 149 if ok and nick_item then
148 display_name = nick_item:get_child_text("nick", "http://jabber.org/protocol/nick"); 150 display_name = nick_item:get_child_text("nick", "http://jabber.org/protocol/nick");
149 end 151 end
150 end 152 end
151 153
154 local groups;
155 do
156 local group_set = group_memberships:get_all(username);
157 if group_set and next(group_set) then
158 groups = {};
159 for group_id in pairs(group_set) do
160 table.insert(groups, group_id);
161 end
162 end
163 end
164
152 return { 165 return {
153 username = username; 166 username = username;
154 display_name = display_name; 167 display_name = display_name;
168 groups = groups;
155 }; 169 };
156 end 170 end
157 171
158 function list_users(event) 172 function list_users(event)
159 local user_list = {}; 173 local user_list = {};