mod_client_management: Prevent exception on missing client info
authorKim Alvefur <zash@zash.se>
Sat, 06 Apr 2024 13:04:35 +0200
changeset 5882 13094c707414
parent 5881 70fa3f8de249
child 5883 bf5370a40a15
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?
mod_client_management/mod_client_management.lua
--- 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