mod_lastlog: Fix traceback if no session included with event (eg from mod_register_web) (thanks biszkopcik)
authorKim Alvefur <zash@zash.se>
Mon, 25 Aug 2014 00:38:14 +0200
changeset 1493 d5e8758d391d
parent 1492 8c4a2d85e8bf
child 1494 02cd4a081db4
mod_lastlog: Fix traceback if no session included with event (eg from mod_register_web) (thanks biszkopcik)
mod_lastlog/mod_lastlog.lua
--- a/mod_lastlog/mod_lastlog.lua	Thu Aug 21 23:14:55 2014 +0200
+++ b/mod_lastlog/mod_lastlog.lua	Mon Aug 25 00:38:14 2014 +0200
@@ -10,7 +10,7 @@
 		datamanager.store(session.username, host, "lastlog", {
 			event = "login";
 			timestamp = time(),
-			ip = log_ip and session.ip or nil,
+			ip = log_ip and session and session.ip or nil,
 		});
 	end
 end);
@@ -21,7 +21,7 @@
 		datamanager.store(session.username, host, "lastlog", {
 			event = "logout";
 			timestamp = time(),
-			ip = log_ip and session.ip or nil,
+			ip = log_ip and session and session.ip or nil,
 		});
 	end
 end);
@@ -31,7 +31,7 @@
 	datamanager.store(event.username, host, "lastlog", {
 		event = "registered";
 		timestamp = time(),
-		ip = log_ip and session.ip or nil,
+		ip = log_ip and session and session.ip or nil,
 	});
 end);