From 94385af697fe46454bee2adf4c75bc0c48ddac33 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 13 Feb 2025 12:21:16 +0000 Subject: mod_invites: Shell command to create reset links --- plugins/mod_invites.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/mod_invites.lua b/plugins/mod_invites.lua index 1dfc8804..de836358 100644 --- a/plugins/mod_invites.lua +++ b/plugins/mod_invites.lua @@ -255,6 +255,24 @@ module:add_item("shell-command", { end; }); +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"; -- cgit v1.2.3