Mercurial > prosody-modules
comparison mod_invites_register_web/mod_invites_register_web.lua @ 4175:39d1a4ecdee6
mod_invites_register_web: Support a 'login_link_format' for apps, redirected to after successful registration
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 06 Oct 2020 16:06:57 +0100 |
| parents | e56b6b6852ae |
| children | 15cf32e666da |
comparison
equal
deleted
inserted
replaced
| 4174:e56b6b6852ae | 4175:39d1a4ecdee6 |
|---|---|
| 6 local st = require "util.stanza"; | 6 local st = require "util.stanza"; |
| 7 local url_escape = require "util.http".urlencode; | 7 local url_escape = require "util.http".urlencode; |
| 8 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, { | 8 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, { |
| 9 urlescape = url_escape; | 9 urlescape = url_escape; |
| 10 }); | 10 }); |
| 11 | 11 local render_url = require "util.interpolation".new("%b{}", url_escape, { |
| 12 urlescape = url_escape; | |
| 13 noscheme = function (url) | |
| 14 return (url:gsub("^[^:]+:", "")); | |
| 15 end; | |
| 16 }); | |
| 12 | 17 |
| 13 module:depends("register_apps"); | 18 module:depends("register_apps"); |
| 14 | 19 |
| 15 local site_name = module:get_option_string("site_name", module.host); | 20 local site_name = module:get_option_string("site_name", module.host); |
| 16 local site_apps = module:shared("register_apps/apps"); | 21 local site_apps = module:shared("register_apps/apps"); |
| 155 | 160 |
| 156 local app_info = site_apps[app_id]; | 161 local app_info = site_apps[app_id]; |
| 157 | 162 |
| 158 local success_template; | 163 local success_template; |
| 159 if app_info then | 164 if app_info then |
| 165 if app_info.login_link_format then | |
| 166 local redirect_url = render_url(app_info.login_link_format, { | |
| 167 site_name = site_name; | |
| 168 username = prepped_username; | |
| 169 domain = module.host; | |
| 170 password = password; | |
| 171 app = app_info; | |
| 172 }); | |
| 173 return { | |
| 174 status_code = 303; | |
| 175 headers = { | |
| 176 ["Location"] = redirect_url; | |
| 177 }; | |
| 178 }; | |
| 179 end | |
| 160 -- If recognised app, we serve a page that includes setup instructions | 180 -- If recognised app, we serve a page that includes setup instructions |
| 161 success_template = assert(module:load_resource("html/register_success_setup.html")):read("*a"); | 181 success_template = assert(module:load_resource("html/register_success_setup.html")):read("*a"); |
| 162 else | 182 else |
| 163 success_template = assert(module:load_resource("html/register_success.html")):read("*a"); | 183 success_template = assert(module:load_resource("html/register_success.html")):read("*a"); |
| 164 end | 184 end |
