changeset 4381:a1256e376dca

mod_invites_register_api: reroute register call The token from the URI was not used anyway. In addition, we now return the resulting JID because it’s the only way to be sure.
author Jonas Schäfer <jonas@wielicki.name>
date Mon, 25 Jan 2021 16:55:39 +0100
parents cba8cd564641
children 0d6b69777bc1
files mod_invites_register_api/mod_invites_register_api.lua
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mod_invites_register_api/mod_invites_register_api.lua	Mon Jan 25 12:44:20 2021 +0000
+++ b/mod_invites_register_api/mod_invites_register_api.lua	Mon Jan 25 16:55:39 2021 +0100
@@ -32,11 +32,7 @@
 	});
 end
 
-function register_with_invite(event, invite_token)
-	if not invite_token or #invite_token == 0 then
-		return 404;
-	end
-
+function register_with_invite(event)
 	local request, response = event.request, event.response;
 
 	if not request.body or #request.body == 0
@@ -106,13 +102,15 @@
 		ip = request.ip;
 	});
 
-	return 200;
+	return json.encode({
+		jid = prepped_username .. "@" .. module.host;
+	});
 end
 
 module:provides("http", {
 	default_path = "register_api";
 	route = {
 		["GET /invite/*"] = get_invite_info;
-		["POST /register/*"] = register_with_invite;
+		["POST /register"] = register_with_invite;
 	};
 });