comparison mod_http_admin_api/mod_http_admin_api.lua @ 5895:095030677ae6

mod_http_admin_api: Support storing free-form text note with invitations
author Matthew Wild <mwild1@gmail.com>
date Mon, 29 Apr 2024 17:49:19 +0100
parents 512f912fdfa5
children
comparison
equal deleted inserted replaced
5894:423163b65bb1 5895:095030677ae6
80 local function token_info_to_invite_info(token_info) 80 local function token_info_to_invite_info(token_info)
81 local additional_data = token_info.additional_data; 81 local additional_data = token_info.additional_data;
82 local groups = additional_data and additional_data.groups or nil; 82 local groups = additional_data and additional_data.groups or nil;
83 local roles = additional_data and additional_data.roles or nil; 83 local roles = additional_data and additional_data.roles or nil;
84 local source = additional_data and additional_data.source or nil; 84 local source = additional_data and additional_data.source or nil;
85 local note = additional_data and additional_data.note or nil;
85 local reset = not not (additional_data and additional_data.allow_reset or nil); 86 local reset = not not (additional_data and additional_data.allow_reset or nil);
86 return { 87 return {
87 id = token_info.token; 88 id = token_info.token;
88 type = token_info.type; 89 type = token_info.type;
89 reusable = not not token_info.reusable; 90 reusable = not not token_info.reusable;
95 expires = token_info.expires; 96 expires = token_info.expires;
96 groups = groups; 97 groups = groups;
97 roles = roles; 98 roles = roles;
98 source = source; 99 source = source;
99 reset = reset; 100 reset = reset;
101 note = note;
100 }; 102 };
101 end 103 end
102 104
103 function list_invites(event) 105 function list_invites(event)
104 local invites_list = {}; 106 local invites_list = {};
154 return 400; 156 return 400;
155 end 157 end
156 invite = invites.create_group(options.groups, { 158 invite = invites.create_group(options.groups, {
157 source = source; 159 source = source;
158 roles = options.roles; 160 roles = options.roles;
161 note = options.note;
159 }, options.ttl); 162 }, options.ttl);
160 elseif invite_type == "account" then 163 elseif invite_type == "account" then
161 invite = invites.create_account(options.username, { 164 invite = invites.create_account(options.username, {
162 source = source; 165 source = source;
163 groups = options.groups; 166 groups = options.groups;
164 roles = options.roles; 167 roles = options.roles;
168 note = options.note;
165 }, options.ttl); 169 }, options.ttl);
166 else 170 else
167 return 400; 171 return 400;
168 end 172 end
169 if not invite then 173 if not invite then