Mercurial > prosody-hg
comparison plugins/mod_invites.lua @ 13673:a186f1cfae75 13.0
mod_invites: Shell command to create reset links
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 13 Feb 2025 12:21:16 +0000 |
| parents | 9cd5b3484a1d |
| children | 1ba58459c919 |
comparison
equal
deleted
inserted
replaced
| 13671:0c8c1a8338d1 | 13673:a186f1cfae75 |
|---|---|
| 256 }); | 256 }); |
| 257 | 257 |
| 258 module:add_item("shell-command", { | 258 module:add_item("shell-command", { |
| 259 section = "invite"; | 259 section = "invite"; |
| 260 section_desc = "Create and manage invitations"; | 260 section_desc = "Create and manage invitations"; |
| 261 name = "create_reset"; | |
| 262 desc = "Create a password reset link for the specified user"; | |
| 263 args = { { name = "user_jid", type = "string" }, { name = "duration", type = "string" } }; | |
| 264 host_selector = "user_jid"; | |
| 265 | |
| 266 handler = function (self, user_jid, duration) --luacheck: ignore 212/self | |
| 267 local username = jid_split(user_jid); | |
| 268 local duration_sec = require "prosody.util.human.io".parse_duration(duration or "1d"); | |
| 269 local invite, err = create_account_reset(username, duration_sec); | |
| 270 if not invite then return nil, err; end | |
| 271 self.session.print(invite.landing_page or invite.uri); | |
| 272 return true, ("Password reset link for %s valid until %s"):format(user_jid, os.date("%Y-%m-%d %T", invite.expires)); | |
| 273 end; | |
| 274 }); | |
| 275 | |
| 276 module:add_item("shell-command", { | |
| 277 section = "invite"; | |
| 278 section_desc = "Create and manage invitations"; | |
| 261 name = "create_contact"; | 279 name = "create_contact"; |
| 262 desc = "Create an invitation to become contacts with the specified user"; | 280 desc = "Create an invitation to become contacts with the specified user"; |
| 263 args = { { name = "user_jid", type = "string" }, { name = "allow_registration" } }; | 281 args = { { name = "user_jid", type = "string" }, { name = "allow_registration" } }; |
| 264 host_selector = "user_jid"; | 282 host_selector = "user_jid"; |
| 265 | 283 |
