mod_easy_invite: Rewrite prosodyctl command handler to support new features (from Snikket)
authorMatthew Wild <mwild1@gmail.com>
Mon, 07 Sep 2020 12:53:35 +0100
changeset 4090 50644402c6f5
parent 4089 fe75cc43dfbf
child 4091 88a469b285f5
mod_easy_invite: Rewrite prosodyctl command handler to support new features (from Snikket)
mod_easy_invite/mod_easy_invite.lua
--- 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
-