comparison mod_invites_register_web/mod_invites_register_web.lua @ 4112:d0366474aace

mod_invites_register_web: Fix traceback on missing query params
author Matthew Wild <mwild1@gmail.com>
date Sat, 12 Sep 2020 10:28:28 +0100
parents f49e3ea99785
children a1c6eea971ce
comparison
equal deleted inserted replaced
4111:ae2699f1cba9 4112:d0366474aace
20 local invites_page = module:depends("invites_page"); 20 local invites_page = module:depends("invites_page");
21 21
22 function serve_register_page(event) 22 function serve_register_page(event)
23 local register_page_template = assert(module:load_resource("html/register.html")):read("*a"); 23 local register_page_template = assert(module:load_resource("html/register.html")):read("*a");
24 24
25 local query_params = http_formdecode(event.request.url.query); 25 local query_params = event.request.url.query and http_formdecode(event.request.url.query);
26 26
27 local invite = invites.get(query_params.t); 27 local invite = query_params and invites.get(query_params.t);
28 if not invite then 28 if not invite then
29 return { 29 return {
30 status_code = 303; 30 status_code = 303;
31 headers = { 31 headers = {
32 ["Location"] = invites.module:http_url().."?"..event.request.url.query; 32 ["Location"] = invites.module:http_url().."?"..(event.request.url.query or "");
33 }; 33 };
34 }; 34 };
35 end 35 end
36 36
37 local invite_page = render_html_template(register_page_template, { 37 local invite_page = render_html_template(register_page_template, {