mod_s2s: Handle authentication of s2sin and s2sout the same way
[prosody.git] / util / adhoc.lua
blobd81b8242701a6c87cbc9bc21e5a043606d9242d3
1 -- luacheck: ignore 212/self
3 local function new_simple_form(form, result_handler)
4 return function(self, data, state)
5 if state then
6 if data.action == "cancel" then
7 return { status = "canceled" };
8 end
9 local fields, err = form:data(data.form);
10 return result_handler(fields, err, data);
11 else
12 return { status = "executing", actions = {"next", "complete", default = "complete"}, form = form }, "executing";
13 end
14 end
15 end
17 local function new_initial_data_form(form, initial_data, result_handler)
18 return function(self, data, state)
19 if state then
20 if data.action == "cancel" then
21 return { status = "canceled" };
22 end
23 local fields, err = form:data(data.form);
24 return result_handler(fields, err, data);
25 else
26 return { status = "executing", actions = {"next", "complete", default = "complete"},
27 form = { layout = form, values = initial_data(data) } }, "executing";
28 end
29 end
30 end
32 return { new_simple_form = new_simple_form,
33 new_initial_data_form = new_initial_data_form };