diff plugins/mod_invites.lua @ 14014:f0b2a05bcedc 13.0

mod_invites: Return error when generating password reset for non-existent account
author Matthew Wild <mwild1@gmail.com>
date Fri, 19 Dec 2025 14:49:50 +0000
parents 17b5a10bd9c9
children 42e035cd3322
line wrap: on
line diff
--- a/plugins/mod_invites.lua	Fri Dec 12 12:43:23 2025 +0000
+++ b/plugins/mod_invites.lua	Fri Dec 19 14:49:50 2025 +0000
@@ -1,5 +1,6 @@
 local id = require "prosody.util.id";
 local it = require "prosody.util.iterators";
+local usermanager = require "prosody.core.usermanager";
 local url = require "socket.url";
 local jid_node = require "prosody.util.jid".node;
 local jid_split = require "prosody.util.jid".split;
@@ -302,10 +303,13 @@
 	};
 
 	handler = function (self, user_jid, opts) --luacheck: ignore 212/self
-		local username = jid_split(user_jid);
+		local username, host = jid_split(user_jid);
 		if not username then
 			return nil, "Supply the JID of the account you want to generate a password reset for";
 		end
+		if not usermanager.user_exists(username, host) then
+			return nil, "The specified user account does not exist: " .. username;
+		end
 		local duration_sec = require "prosody.util.human.io".parse_duration(opts and opts.expires_after or "1d");
 		if not duration_sec then
 			return nil, "Unable to parse duration: "..opts.expires_after;