Software / code / prosody
Annotate
plugins/mod_invites_adhoc.lua @ 13801:a5d5fefb8b68 13.0
mod_tls: Enable Prosody's certificate checking for incoming s2s connections (fixes #1916) (thanks Damian, Zash)
Various options in Prosody allow control over the behaviour of the certificate
verification process For example, some deployments choose to allow falling
back to traditional "dialback" authentication (XEP-0220), while others verify
via DANE, hard-coded fingerprints, or other custom plugins.
Implementing this flexibility requires us to override OpenSSL's default
certificate verification, to allow Prosody to verify the certificate itself,
apply custom policies and make decisions based on the outcome.
To enable our custom logic, we have to suppress OpenSSL's default behaviour of
aborting the connection with a TLS alert message. With LuaSec, this can be
achieved by using the verifyext "lsec_continue" flag.
We also need to use the lsec_ignore_purpose flag, because XMPP s2s uses server
certificates as "client" certificates (for mutual TLS verification in outgoing
s2s connections).
Commit 99d2100d2918 moved these settings out of the defaults and into mod_s2s,
because we only really need these changes for s2s, and they should be opt-in,
rather than automatically applied to all TLS services we offer.
That commit was incomplete, because it only added the flags for incoming
direct TLS connections. StartTLS connections are handled by mod_tls, which was
not applying the lsec_* flags. It previously worked because they were already
in the defaults.
This resulted in incoming s2s connections with "invalid" certificates being
aborted early by OpenSSL, even if settings such as `s2s_secure_auth = false`
or DANE were present in the config.
Outgoing s2s connections inherit verify "none" from the defaults, which means
OpenSSL will receive the cert but will not terminate the connection when it is
deemed invalid. This means we don't need lsec_continue there, and we also
don't need lsec_ignore_purpose (because the remote peer is a "server").
Wondering why we can't just use verify "none" for incoming s2s? It's because
in that mode, OpenSSL won't request a certificate from the peer for incoming
connections. Setting verify "peer" is how you ask OpenSSL to request a
certificate from the client, but also what triggers its built-in verification.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 01 Apr 2025 17:26:56 +0100 |
| parent | 13527:dba43269db5e |
| rev | line source |
|---|---|
|
12145
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- XEP-0401: Easy User Onboarding |
|
12977
74b9e05af71e
plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12642
diff
changeset
|
2 local dataforms = require "prosody.util.dataforms"; |
|
74b9e05af71e
plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12642
diff
changeset
|
3 local datetime = require "prosody.util.datetime"; |
|
74b9e05af71e
plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
12642
diff
changeset
|
4 local split_jid = require "prosody.util.jid".split; |
|
13527
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
5 local adhocutil = require "prosody.util.adhoc"; |
|
12145
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local new_adhoc = module:require("adhoc").new; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 -- Whether local users can invite other users to create an account on this server |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local allow_user_invites = module:get_option_boolean("allow_user_invites", false); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 -- Who can see and use the contact invite command. It is strongly recommended to |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 -- keep this available to all local users. To allow/disallow invite-registration |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 -- on the server, use the option above instead. |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 local allow_contact_invites = module:get_option_boolean("allow_contact_invites", true); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 |
|
13170
082c7d856e61
core, plugins: Split prosody:user role into prosody:{guest,registered,member}
Matthew Wild <mwild1@gmail.com>
parents:
12977
diff
changeset
|
16 module:default_permission(allow_user_invites and "prosody:registered" or "prosody:admin", ":invite-users"); |
|
12145
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local invites; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 if prosody.shutdown then -- COMPAT hack to detect prosodyctl |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 invites = module:depends("invites"); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 end |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 local invite_result_form = dataforms.new({ |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 title = "Your invite has been created", |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 name = "url" ; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 var = "landing-url"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 label = "Invite web page"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 desc = "Share this link"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 }, |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 name = "uri"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 label = "Invite URI"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 desc = "This alternative link can be opened with some XMPP clients"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 }, |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 name = "expire"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 label = "Invite valid until"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 }, |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 }); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 -- This is for checking if the specified JID may create invites |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 -- that allow people to register accounts on this host. |
|
12642
9061f9621330
Switch to a new role-based authorization framework, removing is_admin()
Matthew Wild <mwild1@gmail.com>
parents:
12491
diff
changeset
|
44 local function may_invite_new_users(context) |
|
9061f9621330
Switch to a new role-based authorization framework, removing is_admin()
Matthew Wild <mwild1@gmail.com>
parents:
12491
diff
changeset
|
45 return module:may(":invite-users", context); |
|
12145
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 end |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 module:depends("adhoc"); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
49 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 -- This command is available to all local users, even if allow_user_invites = false |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
51 -- If allow_user_invites is false, creating an invite still works, but the invite will |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 -- not be valid for registration on the current server, only for establishing a roster |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
53 -- subscription. |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
54 module:provides("adhoc", new_adhoc("Create new contact invite", "urn:xmpp:invite#invite", |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
55 function (_, data) |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
56 local username, host = split_jid(data.from); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
57 if host ~= module.host then |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
58 return { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
59 status = "completed"; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
60 error = { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
61 message = "This command is only available to users of "..module.host; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
62 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
63 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
64 end |
|
12642
9061f9621330
Switch to a new role-based authorization framework, removing is_admin()
Matthew Wild <mwild1@gmail.com>
parents:
12491
diff
changeset
|
65 local invite = invites.create_contact(username, may_invite_new_users(data), { |
|
12145
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
66 source = data.from |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
67 }); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
68 --TODO: check errors |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
69 return { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
70 status = "completed"; |
|
13470
19a9ec94f575
mod_invites_adhoc: Fix result form type (thanks betarays)
Kim Alvefur <zash@zash.se>
parents:
12491
diff
changeset
|
71 result = { |
|
12145
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
72 layout = invite_result_form; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
73 values = { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
74 uri = invite.uri; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
75 url = invite.landing_page; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
76 expire = datetime.datetime(invite.expires); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
77 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
78 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
79 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
80 end, allow_contact_invites and "local_user" or "admin")); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
81 |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
82 -- This is an admin-only command that creates a new invitation suitable for registering |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
83 -- a new account. It does not add the new user to the admin's roster. |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
84 module:provides("adhoc", new_adhoc("Create new account invite", "urn:xmpp:invite#create-account", |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
85 function (_, data) |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
86 local invite = invites.create_account(nil, { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
87 source = data.from |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
88 }); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
89 --TODO: check errors |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
90 return { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
91 status = "completed"; |
|
13470
19a9ec94f575
mod_invites_adhoc: Fix result form type (thanks betarays)
Kim Alvefur <zash@zash.se>
parents:
12491
diff
changeset
|
92 result = { |
|
12145
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
93 layout = invite_result_form; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
94 values = { |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
95 uri = invite.uri; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
96 url = invite.landing_page; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
97 expire = datetime.datetime(invite.expires); |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
98 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
99 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
100 }; |
|
212bac94aedd
mod_invites_adhoc: Import from prosody-modules@5001104f0275
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
101 end, "admin")); |
|
13527
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
102 |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
103 local password_reset_form = dataforms.new({ |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
104 title = "Generate Password Reset Invite"; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
105 { |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
106 name = "accountjid"; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
107 type = "jid-single"; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
108 required = true; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
109 label = "The XMPP ID for the account to generate a password reset invite for"; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
110 }; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
111 }); |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
112 |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
113 module:provides("adhoc", new_adhoc("Create password reset invite", "xmpp:prosody.im/mod_invites_adhoc#password-reset", |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
114 adhocutil.new_simple_form(password_reset_form, |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
115 function (fields, err) |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
116 if err then return { status = "completed"; error = { message = "Fill in the form correctly" } }; end |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
117 local username = split_jid(fields.accountjid); |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
118 local invite = invites.create_account_reset(username); |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
119 return { |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
120 status = "completed"; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
121 result = { |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
122 layout = invite_result_form; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
123 values = { |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
124 uri = invite.uri; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
125 url = invite.landing_page; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
126 expire = datetime.datetime(invite.expires); |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
127 }; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
128 }; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
129 }; |
|
dba43269db5e
mod_invites_adhoc: Add password reset command
Kim Alvefur <zash@zash.se>
parents:
13472
diff
changeset
|
130 end), "admin")); |