Software /
code /
prosody
Comparison
plugins/mod_invites_adhoc.lua @ 13527:dba43269db5e
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.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 20 Oct 2024 12:11:21 +0200 |
parent | 13472:d5a9847b0e55 |
comparison
equal
deleted
inserted
replaced
13526:3abed2ec7ab6 | 13527:dba43269db5e |
---|---|
1 -- XEP-0401: Easy User Onboarding | 1 -- XEP-0401: Easy User Onboarding |
2 local dataforms = require "prosody.util.dataforms"; | 2 local dataforms = require "prosody.util.dataforms"; |
3 local datetime = require "prosody.util.datetime"; | 3 local datetime = require "prosody.util.datetime"; |
4 local split_jid = require "prosody.util.jid".split; | 4 local split_jid = require "prosody.util.jid".split; |
5 local adhocutil = require "prosody.util.adhoc"; | |
5 | 6 |
6 local new_adhoc = module:require("adhoc").new; | 7 local new_adhoc = module:require("adhoc").new; |
7 | 8 |
8 -- Whether local users can invite other users to create an account on this server | 9 -- Whether local users can invite other users to create an account on this server |
9 local allow_user_invites = module:get_option_boolean("allow_user_invites", false); | 10 local allow_user_invites = module:get_option_boolean("allow_user_invites", false); |
96 expire = datetime.datetime(invite.expires); | 97 expire = datetime.datetime(invite.expires); |
97 }; | 98 }; |
98 }; | 99 }; |
99 }; | 100 }; |
100 end, "admin")); | 101 end, "admin")); |
102 | |
103 local password_reset_form = dataforms.new({ | |
104 title = "Generate Password Reset Invite"; | |
105 { | |
106 name = "accountjid"; | |
107 type = "jid-single"; | |
108 required = true; | |
109 label = "The XMPP ID for the account to generate a password reset invite for"; | |
110 }; | |
111 }); | |
112 | |
113 module:provides("adhoc", new_adhoc("Create password reset invite", "xmpp:prosody.im/mod_invites_adhoc#password-reset", | |
114 adhocutil.new_simple_form(password_reset_form, | |
115 function (fields, err) | |
116 if err then return { status = "completed"; error = { message = "Fill in the form correctly" } }; end | |
117 local username = split_jid(fields.accountjid); | |
118 local invite = invites.create_account_reset(username); | |
119 return { | |
120 status = "completed"; | |
121 result = { | |
122 layout = invite_result_form; | |
123 values = { | |
124 uri = invite.uri; | |
125 url = invite.landing_page; | |
126 expire = datetime.datetime(invite.expires); | |
127 }; | |
128 }; | |
129 }; | |
130 end), "admin")); |