changeset 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 88a469b285f5
files mod_easy_invite/mod_easy_invite.lua
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_easy_invite/mod_easy_invite.lua	Mon Sep 07 12:52:40 2020 +0100
+++ b/mod_easy_invite/mod_easy_invite.lua	Mon Sep 07 12:53:35 2020 +0100
@@ -247,7 +247,28 @@
 
 	-- Load mod_invites
 	invites = module:context(host):depends("invites");
-	local invite = invites.create_account();
-	print(invite.uri);
+	module:context(host):depends("invites_page");
+
+	table.remove(arg, 1);
+	table.remove(arg, 1);
+
+	local invite, roles;
+	if arg[1] == "--reset" then
+		local nodeprep = require "util.encodings".stringprep.nodeprep;
+		local username = nodeprep(arg[2]);
+		if not username then
+			print("Please supply a valid username to generate a reset link for");
+			return;
+		end
+		invite = invites.create_account_reset(username);
+	else
+		if arg[1] == "--admin" then
+			roles = { ["prosody:admin"] = true };
+		elseif arg[1] == "--role" then
+			roles = { [arg[2]] = true };
+		end
+		invite = invites.create_account(nil, { roles = roles });
+	end
+
+	print(invite.landing_page or invite.uri);
 end
-