Diff

mod_lastlog/mod_lastlog.lua @ 1493:d5e8758d391d

mod_lastlog: Fix traceback if no session included with event (eg from mod_register_web) (thanks biszkopcik)
author Kim Alvefur <zash@zash.se>
date Mon, 25 Aug 2014 00:38:14 +0200
parent 1343:7dbde05b48a9
line wrap: on
line diff
--- 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);