diff options
author | Matthew Wild <mwild1@gmail.com> | 2025-02-13 12:21:16 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2025-02-13 12:21:16 +0000 |
commit | 94385af697fe46454bee2adf4c75bc0c48ddac33 (patch) | |
tree | c1c2c4785dd5a942fbeeed18a76a9b6876476db3 | |
parent | e91c540eea2386d59a5681e1212c1bf33460d870 (diff) | |
download | prosody-94385af697fe46454bee2adf4c75bc0c48ddac33.tar.gz prosody-94385af697fe46454bee2adf4c75bc0c48ddac33.zip |
mod_invites: Shell command to create reset links
-rw-r--r-- | plugins/mod_invites.lua | 18 |
1 files changed, 18 insertions, 0 deletions
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 @@ -258,6 +258,24 @@ module:add_item("shell-command", { 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" } }; |