changeset 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 0016618e0975
files mod_invites_register_web/mod_invites_register_web.lua
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_invites_register_web/mod_invites_register_web.lua	Tue Oct 06 16:06:24 2020 +0100
+++ b/mod_invites_register_web/mod_invites_register_web.lua	Tue Oct 06 16:06:57 2020 +0100
@@ -8,7 +8,12 @@
 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, {
 	urlescape = url_escape;
 });
-
+local render_url = require "util.interpolation".new("%b{}", url_escape, {
+	urlescape = url_escape;
+	noscheme = function (url)
+		return (url:gsub("^[^:]+:", ""));
+	end;
+});
 
 module:depends("register_apps");
 
@@ -157,6 +162,21 @@
 
 		local success_template;
 		if app_info then
+			if app_info.login_link_format then
+				local redirect_url = render_url(app_info.login_link_format, {
+					site_name = site_name;
+					username = prepped_username;
+					domain = module.host;
+					password = password;
+					app = app_info;
+				});
+				return {
+					status_code = 303;
+					headers = {
+						["Location"] = redirect_url;
+					};
+				};
+			end
 			-- If recognised app, we serve a page that includes setup instructions
 			success_template = assert(module:load_resource("html/register_success_setup.html")):read("*a");
 		else