mod_invites_adhoc: Fail contact invite if user is not on current host
authorMatthew Wild <mwild1@gmail.com>
Thu, 28 Jan 2021 07:04:11 +0000
changeset 4413 44f6537f6427
parent 4412 2c47b8110c48
child 4414 d1230d32d709
mod_invites_adhoc: Fail contact invite if user is not on current host Only the username was being used, and the host of the requester ignored. Luckily this only affects admins of the host. If they want to create an account they can use the other command. If they want to create a contact they should request from their account on this host.
mod_invites_adhoc/mod_invites_adhoc.lua
--- a/mod_invites_adhoc/mod_invites_adhoc.lua	Wed Jan 27 16:10:08 2021 +0000
+++ b/mod_invites_adhoc/mod_invites_adhoc.lua	Thu Jan 28 07:04:11 2021 +0000
@@ -44,7 +44,15 @@
 -- subscription.
 module:provides("adhoc", new_adhoc("Create new contact invite", "urn:xmpp:invite#invite",
 		function (_, data)
-			local username = split_jid(data.from);
+			local username, host = split_jid(data.from);
+			if host ~= module.host then
+				return {
+					status = "completed";
+					error = {
+						message = "This command is only available to users of "..module.host;
+					};
+				};
+			end
 			local invite = invites.create_contact(username, allow_user_invites, {
 				source = data.from
 			});