Software / code / prosody-modules
Annotate
mod_invites_register_web/mod_invites_register_web.lua @ 5591:680fb3344357
mod_invites_register_web: Don't register user when refresh `register_error.html`.
| author | Trần H. Trung <work@trung.fun> |
|---|---|
| date | Fri, 26 May 2023 02:15:45 +0700 |
| parent | 5589:c362833be557 |
| child | 5640:5e7e609fae0c |
| rev | line source |
|---|---|
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local id = require "util.id"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 local http_formdecode = require "net.http".formdecode; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local usermanager = require "core.usermanager"; |
|
4167
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
4 local modulemanager = require "core.modulemanager"; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local nodeprep = require "util.encodings".stringprep.nodeprep; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local st = require "util.stanza"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local url_escape = require "util.http".urlencode; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 urlescape = url_escape; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 }); |
|
4175
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
11 local render_url = require "util.interpolation".new("%b{}", url_escape, { |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
12 urlescape = url_escape; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
13 noscheme = function (url) |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
14 return (url:gsub("^[^:]+:", "")); |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
15 end; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
16 }); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 module:depends("register_apps"); |
|
4833
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
19 local mod_password_policy = module:depends("password_policy"); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 local site_name = module:get_option_string("site_name", module.host); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 local site_apps = module:shared("register_apps/apps"); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
|
4167
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
24 local webchat_url = module:get_option_string("webchat_url"); |
|
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
25 |
|
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
26 -- If not provided, but mod_conversejs is loaded, default to that |
|
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
27 if not webchat_url and modulemanager.get_modules_for_host(module.host):contains("conversejs") then |
|
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
28 local conversejs = module:depends("conversejs"); |
|
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
29 webchat_url = conversejs.module:http_url(); |
|
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
30 end |
|
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
31 |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 module:depends("http"); |
|
4108
f49e3ea99785
mod_invites_register_web: Remove dependency on mod_easy_invite
Matthew Wild <mwild1@gmail.com>
parents:
4093
diff
changeset
|
33 |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 local invites = module:depends("invites"); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 local invites_page = module:depends("invites_page"); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 |
|
5589
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
37 local templatePath = module:get_option_string("invites_html_template", "html"); |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
38 function template_get(sTemplate, sLang) |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
39 local template = sLang and templatePath.."/"..sTemplate.."."..sLang..".html" |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
40 or templatePath.."/"..sTemplate..".html"; |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
41 return assert(module:load_resource(template):read("*a")); |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
42 end |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
43 |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
44 local lang = nil; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 function serve_register_page(event) |
|
4112
d0366474aace
mod_invites_register_web: Fix traceback on missing query params
Matthew Wild <mwild1@gmail.com>
parents:
4108
diff
changeset
|
46 local query_params = event.request.url.query and http_formdecode(event.request.url.query); |
|
5589
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
47 lang = query_params and query_params.l; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 |
|
4112
d0366474aace
mod_invites_register_web: Fix traceback on missing query params
Matthew Wild <mwild1@gmail.com>
parents:
4108
diff
changeset
|
49 local invite = query_params and invites.get(query_params.t); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 if not invite then |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 return { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 status_code = 303; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 headers = { |
|
4174
e56b6b6852ae
mod_invites_register_web: Fix bug where invalid invite code redirected to wrong URL
Matthew Wild <mwild1@gmail.com>
parents:
4167
diff
changeset
|
54 ["Location"] = invites_page.module:http_url().."?"..(event.request.url.query or ""); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 }; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 }; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 |
|
5589
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
59 local register_page_template = template_get("register", lang); |
|
4129
ca099bd28bf5
mod_invites_page, mod_invites_register_web: Set correct Content-Type everywhere necessary
Matthew Wild <mwild1@gmail.com>
parents:
4119
diff
changeset
|
60 event.response.headers["Content-Type"] = "text/html; charset=utf-8"; |
|
ca099bd28bf5
mod_invites_page, mod_invites_register_web: Set correct Content-Type everywhere necessary
Matthew Wild <mwild1@gmail.com>
parents:
4119
diff
changeset
|
61 |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 local invite_page = render_html_template(register_page_template, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 site_name = site_name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 token = invite.token; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 domain = module.host; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 uri = invite.uri; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 type = invite.type; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 jid = invite.jid; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 inviter = invite.inviter; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 app = query_params.c and site_apps[query_params.c]; |
|
4833
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
71 password_policy = mod_password_policy.get_policy(); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 return invite_page; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 function handle_register_form(event) |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 local request, response = event.request, event.response; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 local form_data = http_formdecode(request.body); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 local user, password, token = form_data["user"], form_data["password"], form_data["token"]; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 local app_id = form_data["app_id"]; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 |
|
5589
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
82 local register_page_template = template_get("register", lang); |
|
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
83 local error_template = template_get("register_error", lang); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 local invite = invites.get(token); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 if not invite then |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 return { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 status_code = 303; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 headers = { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 ["Location"] = invites_page.module:http_url().."?"..event.request.url.query; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 }; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 }; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 |
|
4129
ca099bd28bf5
mod_invites_page, mod_invites_register_web: Set correct Content-Type everywhere necessary
Matthew Wild <mwild1@gmail.com>
parents:
4119
diff
changeset
|
95 event.response.headers["Content-Type"] = "text/html; charset=utf-8"; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 if not user or #user == 0 or not password or #password == 0 or not token then |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 return render_html_template(register_page_template, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 site_name = site_name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 token = invite.token; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 domain = module.host; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 uri = invite.uri; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 type = invite.type; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 jid = invite.jid; |
|
4833
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
105 password_policy = mod_password_policy.get_policy(); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 msg_class = "alert-warning"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 message = "Please fill in all fields."; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 -- Shamelessly copied from mod_register_web. |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 local prepped_username = nodeprep(user); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 if not prepped_username or #prepped_username == 0 then |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 return render_html_template(register_page_template, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 site_name = site_name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 token = invite.token; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 domain = module.host; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 uri = invite.uri; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 type = invite.type; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 jid = invite.jid; |
|
4833
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
123 password_policy = mod_password_policy.get_policy(); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 msg_class = "alert-warning"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 message = "This username contains invalid characters."; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 if usermanager.user_exists(prepped_username, module.host) then |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 return render_html_template(register_page_template, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 site_name = site_name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 token = invite.token; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 domain = module.host; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 uri = invite.uri; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 type = invite.type; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 jid = invite.jid; |
|
4833
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
138 password_policy = mod_password_policy.get_policy(); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 msg_class = "alert-warning"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 message = "This username is already in use."; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 |
|
4833
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
145 local pw_ok, pw_error = mod_password_policy.check_password(password, { |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
146 username = prepped_username; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
147 }); |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
148 if not pw_ok then |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
149 return render_html_template(register_page_template, { |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
150 site_name = site_name; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
151 token = invite.token; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
152 domain = module.host; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
153 uri = invite.uri; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
154 type = invite.type; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
155 jid = invite.jid; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
156 password_policy = mod_password_policy.get_policy(); |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
157 |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
158 msg_class = "alert-warning"; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
159 message = pw_error; |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
160 }); |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
161 end |
|
15cf32e666da
mod_invites_register_web: Add mod_password_policy checks for web registration
Matthew Wild <mwild1@gmail.com>
parents:
4175
diff
changeset
|
162 |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
163 local registering = { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
164 validated_invite = invite; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
165 username = prepped_username; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
166 host = module.host; |
|
4117
a1c6eea971ce
mod_invites_register_web: Include request.ip in user-registering event (thanks franck)
Matthew Wild <mwild1@gmail.com>
parents:
4112
diff
changeset
|
167 ip = request.ip; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
168 allowed = true; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
169 }; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
170 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
171 module:fire_event("user-registering", registering); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
172 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 if not registering.allowed then |
|
5591
680fb3344357
mod_invites_register_web: Don't register user when refresh `register_error.html`.
Trần H. Trung <work@trung.fun>
parents:
5589
diff
changeset
|
174 prepped_username = nil; |
|
680fb3344357
mod_invites_register_web: Don't register user when refresh `register_error.html`.
Trần H. Trung <work@trung.fun>
parents:
5589
diff
changeset
|
175 password = nil; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
176 return render_html_template(error_template, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
177 site_name = site_name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
178 msg_class = "alert-danger"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
179 message = registering.reason or "Registration is not allowed."; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
180 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
181 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
182 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
183 local ok, err = usermanager.create_user(prepped_username, password, module.host); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
184 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
185 if ok then |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
186 module:fire_event("user-registered", { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
187 username = prepped_username; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
188 host = module.host; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
189 source = "mod_"..module.name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
190 validated_invite = invite; |
|
4119
559ca8d93302
mod_invites_register_web: Also add ip to user-registered
Matthew Wild <mwild1@gmail.com>
parents:
4117
diff
changeset
|
191 ip = request.ip; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
192 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
193 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
194 local app_info = site_apps[app_id]; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
195 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
196 local success_template; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
197 if app_info then |
|
4175
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
198 if app_info.login_link_format then |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
199 local redirect_url = render_url(app_info.login_link_format, { |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
200 site_name = site_name; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
201 username = prepped_username; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
202 domain = module.host; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
203 password = password; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
204 app = app_info; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
205 }); |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
206 return { |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
207 status_code = 303; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
208 headers = { |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
209 ["Location"] = redirect_url; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
210 }; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
211 }; |
|
39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4174
diff
changeset
|
212 end |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 -- If recognised app, we serve a page that includes setup instructions |
|
5589
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
214 success_template = template_get("register_success_setup", lang); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
215 else |
|
5589
c362833be557
mod_invites_register_web: Add html template and URL configuration for multiple (human) language.
Trần H. Trung <work@trung.fun>
parents:
4833
diff
changeset
|
216 success_template = template_get("register_success", lang); |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
217 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
218 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
219 -- Due to the credentials being served here, ensure that |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
220 -- the browser or any intermediary does not cache the page |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
221 event.response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
222 event.response.headers["Pragma"] = "no-cache"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
223 event.response.headers["Expires"] = "0"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
224 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
225 return render_html_template(success_template, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
226 site_name = site_name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
227 username = prepped_username; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
228 domain = module.host; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
229 password = password; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
230 app = app_info; |
|
4167
3a03ae9a0882
mod_invites_register_web: Support linking to a web chat after successful registration
Matthew Wild <mwild1@gmail.com>
parents:
4129
diff
changeset
|
231 webchat_url = webchat_url; |
|
4093
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
232 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
233 else |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
234 local err_id = id.short(); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
235 module:log("warn", "Registration failed (%s): %s", err_id, tostring(err)); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
236 return render_html_template(error_template, { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
237 site_name = site_name; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
238 msg_class = "alert-danger"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
239 message = ("An unknown error has occurred (%s)"):format(err_id); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
240 }); |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
241 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
242 end |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
243 |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
244 module:provides("http", { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
245 default_path = "register"; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
246 route = { |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
247 ["GET"] = serve_register_page; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
248 ["POST"] = handle_register_form; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
249 }; |
|
a2116f5a7c8f
mod_invites_register_web: New module to allow web registration with an invite token
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
250 }); |