diff options
author | Kim Alvefur <zash@zash.se> | 2024-10-20 12:11:21 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2024-10-20 12:11:21 +0200 |
commit | a63544d6cf0825f53cf6a7fe5a1ec8c35219641a (patch) | |
tree | 6ac78dccbdce27e61a3666db69d7bab48402a84d | |
parent | bd90f33e28ee6d405f81f62557ad354769d5838b (diff) | |
download | prosody-a63544d6cf0825f53cf6a7fe5a1ec8c35219641a.tar.gz prosody-a63544d6cf0825f53cf6a7fe5a1ec8c35219641a.zip |
mod_invites_adhoc: Add password reset command
To support cases where the admin does not have easy access to the
command line to generate a password reset invite for someone who forgot
their password.
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | plugins/mod_invites_adhoc.lua | 30 |
2 files changed, 31 insertions, 0 deletions
@@ -74,6 +74,7 @@ TRUNK - Support for Type=notify and notify-reload systemd service type added - Support for the roster *group* access_model in mod_pep - Support for systemd socket activation in server_epoll +- mod_invites_adhoc gained a command for creating password resets ## Removed diff --git a/plugins/mod_invites_adhoc.lua b/plugins/mod_invites_adhoc.lua index c9954d8c..3ef4116d 100644 --- a/plugins/mod_invites_adhoc.lua +++ b/plugins/mod_invites_adhoc.lua @@ -2,6 +2,7 @@ local dataforms = require "prosody.util.dataforms"; local datetime = require "prosody.util.datetime"; local split_jid = require "prosody.util.jid".split; +local adhocutil = require "prosody.util.adhoc"; local new_adhoc = module:require("adhoc").new; @@ -98,3 +99,32 @@ module:provides("adhoc", new_adhoc("Create new account invite", "urn:xmpp:invite }; }; end, "admin")); + +local password_reset_form = dataforms.new({ + title = "Generate Password Reset Invite"; + { + name = "accountjid"; + type = "jid-single"; + required = true; + label = "The XMPP ID for the account to generate a password reset invite for"; + }; +}); + +module:provides("adhoc", new_adhoc("Create password reset invite", "xmpp:prosody.im/mod_invites_adhoc#password-reset", + adhocutil.new_simple_form(password_reset_form, + function (fields, err) + if err then return { status = "completed"; error = { message = "Fill in the form correctly" } }; end + local username = split_jid(fields.accountjid); + local invite = invites.create_account_reset(username); + return { + status = "completed"; + result = { + layout = invite_result_form; + values = { + uri = invite.uri; + url = invite.landing_page; + expire = datetime.datetime(invite.expires); + }; + }; + }; + end), "admin")); |