Changeset

13673:a186f1cfae75 13.0

mod_invites: Shell command to create reset links
author Matthew Wild <mwild1@gmail.com>
date Thu, 13 Feb 2025 12:21:16 +0000
parents 13671:0c8c1a8338d1
children 13674:1ba58459c919
files plugins/mod_invites.lua
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_invites.lua	Wed Feb 12 22:35:39 2025 +0100
+++ b/plugins/mod_invites.lua	Thu Feb 13 12:21:16 2025 +0000
@@ -258,6 +258,24 @@
 module:add_item("shell-command", {
 	section = "invite";
 	section_desc = "Create and manage invitations";
+	name = "create_reset";
+	desc = "Create a password reset link for the specified user";
+	args = { { name = "user_jid", type = "string" }, { name = "duration", type = "string" } };
+	host_selector = "user_jid";
+
+	handler = function (self, user_jid, duration) --luacheck: ignore 212/self
+		local username = jid_split(user_jid);
+		local duration_sec = require "prosody.util.human.io".parse_duration(duration or "1d");
+		local invite, err = create_account_reset(username, duration_sec);
+		if not invite then return nil, err; end
+		self.session.print(invite.landing_page or invite.uri);
+		return true, ("Password reset link for %s valid until %s"):format(user_jid, os.date("%Y-%m-%d %T", invite.expires));
+	end;
+});
+
+module:add_item("shell-command", {
+	section = "invite";
+	section_desc = "Create and manage invitations";
 	name = "create_contact";
 	desc = "Create an invitation to become contacts with the specified user";
 	args = { { name = "user_jid", type = "string" }, { name = "allow_registration" } };