changeset 5878:13094c707414

mod_client_management: Prevent exception on missing client info > attempt to index a nil value (local 'legacy_info') Unsure how exactly this happens, perhaps by mixing SASL2/BIND2 with legacy equivalents?
author Kim Alvefur <zash@zash.se>
date Sat, 06 Apr 2024 13:04:35 +0200
parents 70fa3f8de249
children bf5370a40a15
files mod_client_management/mod_client_management.lua
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mod_client_management/mod_client_management.lua	Sat Mar 30 15:10:51 2024 +0100
+++ b/mod_client_management/mod_client_management.lua	Sat Apr 06 13:04:35 2024 +0200
@@ -116,17 +116,22 @@
 	end
 
 	-- Update state
-	local legacy_info = session.client_management_info;
 	client_state.full_jid = session.full_jid;
 	client_state.last_seen = now;
-	client_state.mechanisms[legacy_info.mechanism] = now;
-	if legacy_info.fast_auth then
-		client_state.fast_auth = now;
-	end
 
-	local token_id = legacy_info.token_info and legacy_info.token_info.id;
-	if token_id then
-		client_state.auth_token_id = token_id;
+	local legacy_info = session.client_management_info;
+	if legacy_info then
+		client_state.mechanisms[legacy_info.mechanism] = now;
+		if legacy_info.fast_auth then
+			client_state.fast_auth = now;
+		end
+
+		local token_id = legacy_info.token_info and legacy_info.token_info.id;
+		if token_id then
+			client_state.auth_token_id = token_id;
+		end
+	else
+		session.log("warn", "Missing client management info")
 	end
 
 	-- Store updated state