comparison mod_easy_invite/mod_easy_invite.lua @ 4086:50644402c6f5

mod_easy_invite: Rewrite prosodyctl command handler to support new features (from Snikket)
author Matthew Wild <mwild1@gmail.com>
date Mon, 07 Sep 2020 12:53:35 +0100
parents fe75cc43dfbf
children 439ae12bb136
comparison
equal deleted inserted replaced
4085:fe75cc43dfbf 4086:50644402c6f5
245 assert(hosts[host], "Host "..tostring(host).." does not exist"); 245 assert(hosts[host], "Host "..tostring(host).." does not exist");
246 sm.initialize_host(host); 246 sm.initialize_host(host);
247 247
248 -- Load mod_invites 248 -- Load mod_invites
249 invites = module:context(host):depends("invites"); 249 invites = module:context(host):depends("invites");
250 local invite = invites.create_account(); 250 module:context(host):depends("invites_page");
251 print(invite.uri); 251
252 end 252 table.remove(arg, 1);
253 253 table.remove(arg, 1);
254
255 local invite, roles;
256 if arg[1] == "--reset" then
257 local nodeprep = require "util.encodings".stringprep.nodeprep;
258 local username = nodeprep(arg[2]);
259 if not username then
260 print("Please supply a valid username to generate a reset link for");
261 return;
262 end
263 invite = invites.create_account_reset(username);
264 else
265 if arg[1] == "--admin" then
266 roles = { ["prosody:admin"] = true };
267 elseif arg[1] == "--role" then
268 roles = { [arg[2]] = true };
269 end
270 invite = invites.create_account(nil, { roles = roles });
271 end
272
273 print(invite.landing_page or invite.uri);
274 end