changeset 4085:fe75cc43dfbf

mod_easy_invite: Allow account reset invites
author Matthew Wild <mwild1@gmail.com>
date Mon, 07 Sep 2020 12:52:40 +0100
parents 9d11c18d4d7e
children 50644402c6f5
files mod_easy_invite/mod_easy_invite.lua
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_easy_invite/mod_easy_invite.lua	Mon Sep 07 12:52:16 2020 +0100
+++ b/mod_easy_invite/mod_easy_invite.lua	Mon Sep 07 12:52:40 2020 +0100
@@ -143,6 +143,9 @@
 		event.reason = "Registration on this server is through invitation only";
 		return;
 	end
+	if validated_invite.additional_data and validated_invite.additional_data.allow_reset then
+		event.allow_reset = validated_invite.additional_data.allow_reset;
+	end
 end);
 
 -- Make a *one-way* subscription. User will see when contact is online,
@@ -191,6 +194,14 @@
 	end
 end);
 
+-- Equivalent of user-registered but for when the account already existed
+-- (i.e. password reset)
+module:hook("user-password-reset", function (event)
+	local validated_invite = event.validated_invite or (event.session and event.session.validated_invite);
+	if not validated_invite then
+		return;
+	end
+	validated_invite:use();
 end);
 
 do